Jump to content

Help with Raptor work!!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
raptorman1

raptorman1

    Newbie

  • Members
  • Pip
  • 2 posts
I need some help with my Raptor homework that I have been having troubles with. If anyone can give me a helping hand I would really appreciate it.

Here are the directions-


Write a program that will calculate the cost of purchasing a meal. This program will include decisions and loops. Details of the program are as follows:
• Your menu items only include the following food with accompanied price:
o Yum Yum Burger = .99
o Grease Yum Fries = .79
o Soda Yum = 1.09
• Allow the user of the program to purchase any quantity of these items on one order.
• Allow the user of the program to purchase one or more types of these items on one order.
• After the order is placed, calculate total and add a 6% sales tax.
• Print to the screen a receipt showing the total purchase price.

Your sample output might look as follows:

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 3
Do you want to end your order? (Enter yes or no): no

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): no

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 1
Do you want to end your order? (Enter yes or no): no

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): yes

The total price is $ 8.1832
Do you want to end program? (Enter no to process a new order): no

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): no

Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): yes

The total price is $ 3.9856
Do you want to end program? (Enter no to process a new order): yes


Here is the Pseudocode-
Module main()
	//Declare local variables
	Declare String endProgram = “no”
	Declare String endOrder = “no”
	Declare Real totalBurger
	Declare Real totalFry
	Declare Real totalSoda
	Declare Real total
	Declare Real tax
	Declare Real subtotal
	Declare Integer option
	Declare Integer burgerCount
	Declare Integer fryCount
	Declare Integer sodaCount
	 
	//Loop to run program again
	While endProgram == “no”
		//reset variables
		totalBurger = 0
		totalFry = 0
		totalSoda = 0
		total = 0
		tax = 0
		subtotal = 0
		
		//Loop to take in order
		While endOrder == “no”
			Display “Enter 1 for Yum Yum Burger”
			Display “Enter 2 for Grease Yum Fries”
			Display “Enter 3 for Soda Yum”
			Input option
			If option == 1 Then
				Call getBurger(totalBurger, burgerCount)
			Else If option == 2 Then
				Call getFry(totalFry, fryCount)
			Else If option == 3 Then
				Call getSoda(totalSoda, sodaCount)
			End If
		
Display “Do you want to end your order? (Enter no to add more items: )”
Input endOrder
		End While
	
	Call calcTotal(burgerTotal, fryTotal, sodaTotal, total, subtotal, tax)
	Call printReceipt(total)

	Display “Do you want to end the program? (Enter no to process a new order)”
	Input endProgram
End While
	
End Module

Module getBurger(Real Ref totalBurger, Integer burgerCount)
	Display “Enter the number of burgers you want”
	Input burgerCount	
	Set totalBurger = totalBurger + burgerCount * .99
End Module

Module getFry(Real Ref totalFry, Integer fryCount)
	Display “Enter the number of fries you want”
	Input fryCount	
	Set totalFry = totalFry + fryCount * .79
End Module

Module getSoda(Real Ref totalSoda, Integer sodaCount)
	Display “Enter the number of sodas you want”
	Input sodaCount	
	Set totalSoda = totalSoda + sodaCount * 1.09
End Module

Module calcTotal(Real totalBurger, Real totalFry, Real totalSoda, Real Ref total, Real subtotal, Real tax)
	Set subtotal = totalBurger + totalFry + totalSoda
	Set tax = subtotal * .06
	Set total = subtotal + tax
End Module

Module printReceipt(Real total)
	Display “Your total is $”, total
End Module
Please help me out!! thx

Edited by WingedPanther, 04 November 2009 - 08:19 AM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What part isn't working right? What are you having difficulty with?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
raptorman1

raptorman1

    Newbie

  • Members
  • Pip
  • 2 posts
Im having trouble just in general starting the process in raptor! I need help getting started with everything.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Are you having issues turning it into a flowchart? Are you having issues with the logic? Something else?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog