Question about Compilers & Programming Tools

1 Answer

Flowcharting create a flowchart that takes as input two numbers and should display the sum,difference and product of the two numbers

Posted by on

  • kiboy Jul 07, 2008

    create aflowchart that takes as input two numbers and should display the sum difference and product

×

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Novelist:

    An expert who has written 50 answers of more than 400 characters.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 160 Answers

Input FirstNumber
Input SecondNumber
Sum= FirstNumber + SecondNumber
If FirstNumber > SecondNumber
Diff=FirstNumber-SecondNumber
Else
Diff=SecondNumber - FirstNumber
END IF
Product = FirstNumber * SecondNumber

Posted on Jul 16, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Create a program that will input 10 grades (75:passing, 79-84:C, 85-89:B, 90-94:A, 95:A+). It will display the average grade.


This can be done in various of ways ,

a quick C implementation of this could be -

#define NUM_OF_GRADES 10
/*
This function will average 10 grades and display their average .
*/
short AverageGrade()
{
short sumOfGrades = 0; //Saves the sum of the grades .
short i = 0; //Iterator
for (i=0;i<NUM_OF_GRADES;i++)
{
printf("Please enter a grade:\t");
sumOfGrades += scanf("%hd",&sumOfGrades);
}//for

return sumOfGrades;
}//AverageGrade

You can either implement the printing of the average inside the function or from the calling function .

Hope this somehow helps ,

Have a great day !

-Danny

Oct 14, 2012 | Program Arts Software C-Free

1 Answer

Create javascript code whose function is to compute the sum of two inputs?


Hello,
The following code will dynamically calculate the some of the first two fields:



Enter first number:
Enter second number:
Their sum is:

Best Regards, Ben

Jun 29, 2011 | Compilers & Programming Tools

1 Answer

Draw a flowchart to enter a number from 1 to 7 and display the corresponding day of the week


1 rem zero out all variables housekeeping

10 let a=0
15 clear $today

16 rem get input

17 input a

19 rem choose corresponding day of the week

20 rem case structure
25 if a=1 then $today="sunday"
30 if a=2 then $today="tuesday"
rem ect til saturday

rem use data created

40 print "today is";$today


Apr 27, 2011 | Compilers & Programming Tools

1 Answer

Declare 2 arrays with 5 as index value of each. the user will input values to the first array(user-defined). Transfer value of the first array to the second array.Get the sum of the second...


You could do this by creating two arrays as such:
int firstArray[5]; int secondArray[5]
and then the sum variable:
int sum = 0;
then you could do a for loop to find the sum of the second array:

Feb 22, 2011 | Microsoft Visual C++ Professional Edition...

1 Answer

Draw a flowchart to enter a number from 1 to 7 and display the corresponding day of the week.


Dunno what language you need but it'd be a simple:
User Input -> if 1 -> "Sunday" '-> else if 2 -> "Monday" '-> else if 3 -> "Tuesday" '-> else if 4 -> "Wednesday" '-> else if 5 -> "Thursday" '-> else if 6 -> "Friday" '-> else if 7 -> "Saturday" '-> else -> "Invalid input entered"

Feb 06, 2011 | Compilers & Programming Tools

1 Answer

A Program using an array that culculates the sum and average of the five input values?


Hi,
I am writing in C code here
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,sum=0;
float avg=0;
printf("enter the five values");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
for(i=0;i<5;i++)
sum+=a[i];
printf("Sum=%d",sum);
avg=sum/5;
printf("Average=%f",avg);
getch();
}

Mar 18, 2009 | ArcMedia JavaScript Source Code 3000 Pro...

1 Answer

MS Access


This will depend upon the question/option made. Anyway, sum / count the number of option having same answer and take the percentage. You will surely see how to make the conclusion.

May 05, 2008 | Microsoft Compilers & Programming Tools

1 Answer

Java gui code


Okay. I'll try and explain what this code is doing for you.

First thing you need to understand is your "gui" is what is known as "Standard Out" and "Standard In", this is how Java outputs text to the console, and how it inputs text written by a user from the console. A function like "System.out.println([some string])" will print out that line to the console.

Second thing is the idea of classes. A class can be thought of like a code "blueprint". You write the blueprint, and then you create individual "objects" based on that class in your code. While each object is independant, and has it's own properties, functions, and its own spot in memory, it is based on the same code.

If I made a class called, say, "Shape", and I gave it two properties, "Size" and "Color", then I could in my program make lots of different "Shape" objects and they would each have their own independant sizes and colors. Yet, if I made a function in the class called "Draw" which magically drew it on the screen in the appropriate size and color that I had specified, I could call "Draw" for each object, and each shape would be drawn on teh screen. The same code is being executed for each shape, but with different values for the size and color, since each shape object is its own unique entity with its own size and color.

The whole point of classes is so that you don't rewrite code. If you needed to have 1000 shapes on the screen, it would be silly to write the drawing code out 1000 times, one for each shape. It's much easier to write a single blueprint that applies to all shapes.

That said, your code above has a number of "classes" at work.

The "Products" class is a class which stores information about a "Product". In your case, this info looks like it is the name of the product, it's price, how many are in stock etc.

The "Inventory" class is a class who's purpose it is to keep track of an array of products. There are a bunch of functions inside this class. I'll describe what they do below


The buildinventory() function appears to build up a list of products for use in the inventory. Notice how it calls the line:

product[0] = new Product(1, "socket set", 3, 19.99);
filling up the "product" array? Each call there created a new "Product" object which was based on the "Product" class. So each object has it's own name, inventory number, stock, price etc, but they all have the same set of functions to do things like, say, get the price of the product (the getPrice() function), or get the name of the product (the getName() function). It's the same function, as defined in the Product class, but when called on a different product object, it will return different results. This works well for an inventory program.

The "DisplayInventory" function loops through all of the products that the inventory class has created, and outputs information about each one to the screen. By the looks of it it is also keeping track of the total value of the inventory, in a variable called "totalPrice". Every time it loops through a product, it adds the product's price onto the total. The idea is once that while loop has finished, that variable will hold the final "total" of the inventory. After the loop has finished you can do a System.out.println() and use that variable to display the final total. This is probably part of what your project is asking you to do.

The "SortInventoryByName" function simply sorts the list of products that the Inventory class has created based on the name of the product. It does this using a build in Java class that you don't need to worry about.

You'll notice a function that is just called "Inventory()" near the top. This is called the "constructor". When you create a class, the class sometimes has to do a bit of initialization work before it is usable. This function is called as soon as the class is instantiated as an object somewhere in your code. So in this case, when you eventually create an inventory object, that function will be called and the inventory will be built (by calling buildInventory()), sorted (by calling sortInventoryByName()), and displayed (by calling displayInventory()).

------------

So it looks like you have this great Inventory class that does everything you need it to do. So now what? It still doesn't do anything! The reason is because it itself is just a class. It's a BLUEPRINT for an inventory. You need a Java program to USE the inventory class to actually do something useful.

You need to make a java program with a sub main() in it (just like every program you've ever made in this class). And inside there initialize a new inventory object, just like how the inventory object made product objects.
e.g.
Inventory myInventory = new Inventory();

Remember the Inventory() constructor! It will get called here, and the inventory class will go ahead and build an inventory, sort it, and display it on the screen.


So hopefully this will help you to understand your class a bit better. Again, real programmers don't just take classes and use them, they need to understand how they work. It's true that occasionally you can find something that does what you need it to do, and you don't need to "Reinvent" the wheel, but if you are unable to understand what it is doing, you can never modify it or tweak it, and if your problem isn't perfectly solved using the class, the class is useless to you. Programmers write their own modules and re-use them as they see fit, and occasionally they use someone else's code as a template. This is why you are learning how to modify an existing class.

Jan 26, 2008 | Compilers & Programming Tools

Not finding what you are looking for?
Compilers & Programming Tools Logo

Related Topics:

323 people viewed this question

Ask a Question

Usually answered in minutes!

Top Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Fred Block
Fred Block

Level 2 Expert

289 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18299 Answers

Are you a Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...