Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,911 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,192 people online right now. Registration is fast and FREE... Join Now!




help thanks!

 
Reply to this topicStart new topic

help thanks!

c++izhere
12 Dec, 2007 - 11:54 AM
Post #1

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 41


My Contributions
[pseudo]

You have been asked to design a program to calculate the areas of 2 rectangles and then indicate whether the area of the first rectangle is less than, greater than, or equal to the area of the second rectangle. The program should prompt the user to enter the length and width of each rectangle. The general formula for the area of a rectangle is as follows:
area = length * width
Create the PSEUDOCODE and NASSI-SCNEIDERMAN diagram for this program.


this is what i have:



1.Start program
2.Prompt for "enter rec1 or rec2"
3.If tri1 display "rectangle 1"
3.1 display"enter length and width"
3.2 return to step 2
Else
4. If tri2 display "rectangle 2"
4.1 display"enter length and width"
5. Calculate area as length*width
5.1 Display total area for rec1 as,"Tarea1"
5.2 save Tarea1
6. Display total area for rec2 as
,Tarea2"
6.2 save Tarea2
7. Read Tarea1 and Tarea2
7.1 if Tarea1 is greater display rec1 greater"
else
7.2 if Tarea is less display"rec2 greater"
else
7.3 display "Tare1 and Tare2 equal"
End program






problem 2(help) nassi diagram help to



You have been asked to design a program to calculate the total amount of a purchase of various fruits and the amount of change received from a $20 bill. The types of fruit available and their costs are as follows:
Bananas are 5 cents each
Apples are 10 cents each
Oranges are 15 cents each
The program should prompt the user to enter the type of fruit (“B” for bananas; “A” for apples; “O” for oranges) and the units of each fruit desired. The user must enter all 3 types of fruit and the quantity of each. The general formula for calculating the amount of the purchase is as follows:
purchase_amount = fruit_cost * units_purchased
Create the PSEUDOCODE and NASSI-SCNEIDERMAN diagram for this
program.


Start program
Display " Enter b,a,o"
If b display "bananas are 5cents ea."
display "enter amount"
else
if a display "apples are 10cents ea."
display "enter amount"
else
if o display "oranges are 15cents ea."
display "enter amount"
calculate purchase_ amount is fruit_cost*units_purchased
end

how to do i incorporate the $20 in this problem

#3
Using the basic requirements from the previous problem, modify your design as follows:
Permit the user to purchase ONLY and NOT ALL of the types of fruit desired and their quantities.
Determine whether or not $20 is sufficient to purchase the amounts and types of fruits desired.
Use a value of “Z” to indicate no more fruit is to be purchased, and display the message “YOU NEED MORE MONEY FOR THIS PURCHASE” if the calculated purchase amount exceeds $20.
Create the PSEUDOCODE and NASSI-SCNEIDERMAN diagram for this program

This post has been edited by c++izhere: 12 Dec, 2007 - 01:00 PM
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Help Thanks!
12 Dec, 2007 - 12:07 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,351



Thanked: 51 times
Dream Kudos: 25
My Contributions
So what's the problem?
User is online!Profile CardPM
+Quote Post

c++izhere
RE: Help Thanks!
12 Dec, 2007 - 12:19 PM
Post #3

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 41


My Contributions
QUOTE(Amadeus @ 12 Dec, 2007 - 01:07 PM) *

So what's the problem?



im just seeing if what i have is correct
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Help Thanks!
12 Dec, 2007 - 12:40 PM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
It appears you need more practice on reading the problem and translating it to pseudocode.

1) Your first problem you mention triangles when the problem deals with rectangles. Secondly, you don't need to return to step two after you taken your inputs for the second rectangle. You can proceed on to step 5. Third, no where do you compare the size of the two rectangles. The problem said you need to compare the areas and determine which is bigger, smaller or if they are the same size.

2) This one you have a good start, but where do you take the input for each of the fruit types? You display the fruit name and price, but then never ask for the amount they want. Each of those prompts have to follow the message. Then to figure out the amount from 20 dollars, you multiple the amount of each fruit times its price to get a total for each fruit, add the three fruit types together and subtract that from the 20 dollars.

3) Using the code you develop for number 2, simply allow them to only buy one type of fruit, multiple that amount against its price and see if the total is greater than 20.00. So for instance if they buy apples at ten cents each and they order 300 then you would go... 300 * .10 = 30 dollars and is 30.00 > 20.00? Yes, print message that they need more money.

I hope that helps put you back on track. smile.gif
User is offlineProfile CardPM
+Quote Post

c++izhere
RE: Help Thanks!
12 Dec, 2007 - 12:48 PM
Post #5

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 41


My Contributions
QUOTE(Martyr2 @ 12 Dec, 2007 - 01:40 PM) *

It appears you need more practice on reading the problem and translating it to pseudocode.

1) Your first problem you mention triangles when the problem deals with rectangles. Secondly, you don't need to return to step two after you taken your inputs for the second rectangle. You can proceed on to step 5. Third, no where do you compare the size of the two rectangles. The problem said you need to compare the areas and determine which is bigger, smaller or if they are the same size.

2) This one you have a good start, but where do you take the input for each of the fruit types? You display the fruit name and price, but then never ask for the amount they want. Each of those prompts have to follow the message. Then to figure out the amount from 20 dollars, you multiple the amount of each fruit times its price to get a total for each fruit, add the three fruit types together and subtract that from the 20 dollars.

3) Using the code you develop for number 2, simply allow them to only buy one type of fruit, multiple that amount against its price and see if the total is greater than 20.00. So for instance if they buy apples at ten cents each and they order 300 then you would go... 300 * .10 = 30 dollars and is 30.00 > 20.00? Yes, print message that they need more money.

I hope that helps put you back on track. smile.gif



it sure did.thanks alot. but how would i be able to that in problem #1 that one is greater less than or equal
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Help Thanks!
12 Dec, 2007 - 12:50 PM
Post #6

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well you multiply the width and height and save the value. Do the same with rectangle two and then you would compare, is variable 1 greater than variable 2? Else if variable 1 less than variable 2? Else, they are equal.

smile.gif
User is offlineProfile CardPM
+Quote Post

c++izhere
RE: Help Thanks!
12 Dec, 2007 - 01:00 PM
Post #7

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 41


My Contributions
QUOTE(Martyr2 @ 12 Dec, 2007 - 01:50 PM) *

Well you multiply the width and height and save the value. Do the same with rectangle two and then you would compare, is variable 1 greater than variable 2? Else if variable 1 less than variable 2? Else, they are equal.

smile.gif


i modified it.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 01:55PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month