!The $20-a-day Challenge
! This program is based off of The FoodNetwork's "$40-a-day" TV Show.
! The object of the challenge is for the user to spend less than $20 for the entire day of meals: breakfast, lunch, and dinner.
! The user has the option of eating 3 meals or less and is given a menu of food items that the user can select from.
! The program asks the user if the user would like to eat a meal and ask the user to select a food, and the program displays the individual price.
! The program then gives the total price for each meal after the user declines any more desired food items.
! At the end of 3 meals, the program lets the user know whether or not they stayed within the $20 budget.
! The program also determines how much coin change the user would receive if he/she gives a certain dollar amount.

!LIST OF COMMANDS
!1) Change font & font size
!2) Change font color
!3) Print Repeat$
!4) Input Statement with a Prompt
!5) Ucase$
!6) Loop until
!7) Do-Loop
!8) Sum
!9) IF-THEN-ELSE-End IF
!10) Restore Statement
!11) Ip and Fp Functions
!12) Truncate Function
!13) SELECT CASE
!14) Clear
!15) Graphic Picture
!16) Key Input Test
!17) Sound

!Dim, Let, Call Object, Set Color, Repeat$(), pause, Input, Ucase$(), Do-Loop, String Concatation, Restore, Read-data, more-data, If-Else, Val(), Ip(), Fp(), Truncate(), Select Case, pause, Clear, Sound, key Input

!changes font
DIM v(1)
LET fn$ = "Courier"  
LET fs$ = "Bold"     
LET v(1) = 14        
CALL Object (2, 0, "FONT NAME|FONT STYLE|FONT SIZE", fn$ & "|" & fs$, v())
!changes color of the font
SET COLOR "green"      
Print "The $20-a-day Challenge"
PRINT
PRINT Repeat$("$20 ", 27)
PRINT          !displays a blank line
pause .5       !waits .8 seconds before the next command shows up

SET COLOR "blue"
INPUT prompt "Good Morning! What is your name? ": Name$
!INPUT Statement with a Prompt (asks the user for name and uses it in the next line response)
PRINT

LET Name$ = Ucase$(Name$)
! Converts the user name to uppercase letters for Name$

PRINT "Hello "; Name$; "! Welcome to the $20-a-day challenge."
PRINT

LET Line$ = "You have $20 to spend on your meals for the day. Let's get started!"

Do
     PRINT Line$
     INPUT prompt "Are you ready (Y/N)?": More$
Loop until UCase$(More$) = "Y"
! Loop until statement causes the loop to repeat until the logical expression becomes typed by user
PRINT

 

LET Line$ = "Breakfast is the most important meal of the day."

LET Sum = 0
LET break = 0
LET lun = 0
LET din = 0
! allows the program to add up the total for each meal after the user has selected all the food items for the meal
DO
! DO and LOOP Statement
! Tells the program to repeat this block for Breakfast, Lunch, and Dinner
     PRINT Line$
     INPUT prompt "Would you like to eat breakfast (Y/N)? ": More$
LOOP until UCase$(More$) = "Y" or UCase$(More$) = "N"
IF UCase$(More$) = "Y" then
! IF-THEN-ELSE-END IF
! depending on the choice of the user, a different output is displayed
PRINT
LINE INPUT prompt "For Breakfast, you have the option of having: Toast, Bagel, Waffles, Pancakes, Omelette, Eggs Benedict, Yogurt, Cereal, Milk, Orange Juice, Coffee. What would you like? ": Breakfast$
DO until Breakfast$ = ""
     RESTORE
     Do while More data
          READ Food$, Cost$
     IF UCase$(Breakfast$) = UCase$(Food$) then EXIT DO
     LOOP

     IF Food$ = "ZZZZZZ" then
          Print "This is not an item on the menu."
     ELSE
          Print "The price for "; Food$, " is $"; Cost$
     LET break = break + Val(Cost$)
     END IF
     LINE INPUT prompt "Anything else? (Type item or No) ": Breakfast$

 

LOOP until UCase$(Breakfast$) = "NO"
! Repeats the loop until user does not want any more food items
PRINT

LET sum = sum + break
Print "The total price for breakfast is $"; break
Print "The total amount spent so far is $"; sum
!prints the sum of the cost for the meal

! The Restore Statement
! displays the appropriate price for the food when entered by the user
DATA Toast, 1.99, Bagel, 2.50
DATA Waffles, 5.99, Pancakes, 4.99
DATA Omelette, 5.25, Eggs Benedict, 4.99
DATA Hashbrowns, 3.50, Yogurt, 2.29
DATA Cereal, 2.79, Milk, 1.35
DATA Orange Juice, 2.00, Coffee, 1.50
DATA ZZZZZZ, 0
ELSE
print "Ok, on to lunch."
END IF

PRINT

Do
     INPUT prompt "Would you like to eat Lunch (Y/N)? ": Mores$
LOOP until UCase$(More$) = "Y" or UCase$(More$) = "N"
IF UCase$(Mores$) = "Y" then
PRINT
LINE INPUT prompt "For Lunch, the menu consists of Sandwich, Pizza, Hamburger, French Fries, Chicken Fingers, Salad, Soup. What would you like for lunch? ": Lunch$
DO until Lunch$ = ""
     RESTORE
     Do while More data
          READ SecondFood$, SecondCost$
     IF UCase$(Lunch$) = UCase$(SecondFood$) then EXIT DO
     LOOP

     IF SecondFood$ = "ZZZZZZ" then
          Print "This is not an item on the menu."
     ELSE
          Print "The price for "; SecondFood$, " is $"; SecondCost$
     LET lun = lun + Val(SecondCost$)
     END IF
     LINE INPUT prompt "Anything else? (Type item or No) ": Lunch$
LOOP until UCase$(Lunch$) = "NO"
PRINT

LET sum = sum + lun
Print "The total price for Lunch is $"; lun
Print "The total amount spent so far is $"; sum

DATA Sandwich, 6.99, Pizza, 4.29
DATA Hamburger, 6.99, French Fries, 2.79
DATA Chicken Fingers, 7.49, Salad, 4.95
DATA Soup, 3.95, ZZZZZZ, 0
ELSE
Print "Ok, on to Dinner then."
END IF
PRINT

Do
     INPUT prompt "Would you like to eat Dinner (Y/N)? ": Moress$
LOOP until UCase$(More$) = "Y" or UCase$(More$) = "N"
IF UCase$(Moress$) = "Y" then
PRINT
LINE INPUT prompt "For Dinner, the menu consists of Pasta, Steak, Chicken, Salmon, Giant Potato, Calzone, Lasagna, Salad. What would you like for Dinner? ": Dinner$
DO until Dinner$ = ""
     RESTORE
     Do while More data
          READ ThirdFood$, ThirdCost$
     IF UCase$(Dinner$) = UCase$(ThirdFood$) then EXIT DO
     LOOP

     IF ThirdFood$ = "ZZZZZZ" then
          Print "This is not an item on the menu."
     ELSE
          Print "The price for "; ThirdFood$, " is $"; ThirdCost$
     LET din = din +Val(ThirdCost$)
     END IF
     LINE INPUT prompt "Anything else? (Type item or No) ": Dinner$
LOOP until UCase$(Dinner$) = "NO"
PRINT

LET sum = sum + din
Print "The total price for Dinner is $"; din
Print "The total amount spent so far is $"; sum

DATA Pasta, 9.95, Steak, 12.95
DATA Chicken, 10.95, Salmon, 13.45
DATA Giant Potato, 8.25, Calzone, 8.99
DATA Lasagna, 9.95, Salad, 7.95
DATA ZZZZZZ, 0
ELSE
END IF

PRINT

PRINT "The total money spent on meals for the day is $"; Sum

!The Fp and Ip Functions
! Ip returns the integer part
! Fp returns the fractional part (the digits after the decimal)
LET a = Ip(Sum)
PRINT "To break it down, you spent"; a; " dollars";
LET b = Fp(Sum)
PRINT "and"; b; " cents."

!Truncate Function
! I wanted to round the total amount to the next dollar, so I used the truncate function to do this.
! This way, I can suggest the amount of dollar bills the user can give to me and the change he/she receives if this were a real money transaction.
LET c = Truncate(sum, 0) +1
PRINT "If you give me"; c; " dollars, I can give you";
LET d = c - sum
PRINT d; " for change."
PRINT

! SELECT CASE Statement
! In order to determine whether the user passed the $20-a-day challenge of spending $20 or less for the entire day of meals, this command displays the result based upon the sum
SELECT CASE Sum
CASE is <20
     PRINT "You stayed within the budget! Nice work!"
CASE 20 to 20
     PRINT "You spent exactly $20. WOW! Great job!"
CASE is >20
     PRINT "You spent too much money! You failed the challenge."
End select

 

Pause 4
Clear
! clears the screen and changes the entire screen to an output window
! Displays a picture of a graphic
LET x=.2
LET y=.2
CALL Read_image ("JPEG", image$, "chef.jpg")
BOX Show image$ at x,y

! The Key Input Test
! Sounding a tone on the computer until a key is pressed
! The program will generate a tone of frequency 500 hertz that lasts for a duration of 2 seconds.
PRINT "Press any key to turn off the sound."
DO until Key Input
SOUND 500, 0.5
PAUSE 1
Loop

End