Cash Register help 
	 
	
		| Author | 
		Message | 
	 
		 
		osmanrulz
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Nov 24, 2006 4:53 pm    Post subject: Cash Register help  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Erm iv written a a small cash register program, thats finds out the name of a restuarant and accepts the price for a meal and prints the bill. What i have been instructed is.. if the meal if over $5.00, i shud display a 7% sales tax. The program is assigned to work if several meals are entered for one bill, which i have trouble modifying, It  should also work for several customers (different bills). Now I only have been close to the midterm of my programming class and all i know is loops and selection, if statements and end statements and all the basic stuff. How can i make this program work for several meals entered for one bill, and then calculating that with a salestax or without it. This is what I have completed so far.
 
 
	  | code: | 	 		  
 
%Osman Ahmad
 
%Finds the Total Cost of Your meal and adds a 7% tax if greater than 5 dollars
 
%November 21/06
 
var cost, total, cash, salestax : real
 
var restuarantName : string
 
 
put "*********************************************"
 
loop
 
put "What is the Restuarant Name?"
 
get restuarantName : *
 
put "| Welcome to ", restuarantName
 
put "************************************************"
 
put "Please enter the amount of your meal: " ..
 
get cost
 
put "*********************************************************"
 
if cost <= 5.00 then
 
   total := cost
 
       put "You have no sales tax, your meal does not exceed $5.00!" 
 
       put "Salestax (0%): $0.00"
 
       put "Tax Total (You do not have a tax): $0.00"
 
 
        put "Grand Total is: $", total
 
        put "*****************************************************"
 
        put "Please enter your amount of cash (Bill or overall change): $" ..
 
        get cash
 
        cash := total - cash
 
        put "***************************************************"
 
        total := cost + salestax
 
        cash := total - cash
 
        if total >= cash then
 
            put " Please give right amound of cash: $", cash - total
 
        elsif cash >= total then
 
            put "Your change is: $", cash - total
 
 
        end if
 
        put "*************************************************"
 
        put "Thanks for Purchasing at " , restuarantName
 
        put "***********************************************"
 
  
 
  
 
elsif cost >= 5 then
 
    salestax := cost * .07
 
    put "You have a sales tax of 7%, your meal exceeds $5.00!"
 
 
 
    put "Salestax (7%): $", salestax
 
 
    put "Tax Total: $", salestax
 
    total := cost + salestax
 
    put "Grand Total is: $", total
 
    put "****************************************"
 
    put "Please enter your amount of cash (Bill or overall change): $" ..
 
    get cash
 
    cash := total - cash
 
    put "************************************************"
 
    total := cost + salestax
 
    cash := total - cash
 
    if total >= cash then
 
        put  Please give right amound of cash: $", cash - total
 
    elsif cash >= total then
 
        put "Your change is: $", cash - total
 
        put   "Next Customer"
 
      put "Thanks for Purchasing at " , restuarantName
 
        put "*******************************************"
 
 
end if
 
end if
 
end loop
 
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		osmanrulz
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Nov 24, 2006 5:10 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				oh and sorry I didnt post this in the first message, I also need to round the total to 2 decimal places, and i forgot how to do that  , so if I could have help with that too. Thanks. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		ericfourfour
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Nov 24, 2006 8:05 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Well Turing has a nifty round function that rounds off the decimals.
 
 
 
You want it to round to two decimal places so somehow you are going to have to move the decimal, round the number, and move the decimal back. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		DemonZ
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Nov 25, 2006 2:56 am    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				why not just use fields? same thing and simple heres an example
 
put money:0:2 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		osmanrulz
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Nov 25, 2006 9:52 am    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				DemonZ wrote: why not just use fields? same thing and simple heres an example
 
put money:0:2 
 
yess thanks so much, so it should me something like this? , I still have this annoying error that keeps popping up when I enter an amound for my meal i.e 4.22 and I enter say 5.22 for my Bill, it gives me a no variable error. Also I would like to know how I can make it calculate and input/output multiple meals, using for statements, but I seem to be having trouble doing that. It should be something like this.
 
put "How many meals would you like to order.."
 
get numMeals
 
put "What is the Price of meal 1?"
 
put "What is the Price of meal 2?" ... etc
 
	  | code: | 	 		  
 
%Osman Ahmad
 
%Finds the Total Cost of Your meal and adds a 7% tax if greater than 5 dollars
 
%November 21/06
 
var cost, total, cash, salestax : real
 
var restuarantName : string
 
 
put "*********************************************"
 
loop
 
    put "What is the Restuarant Name?"
 
    get restuarantName : *
 
    put "| Welcome to ", restuarantName
 
    put "************************************************"
 
    put "Please enter the amount of your meal: " ..
 
    get cost
 
    put "*********************************************************"
 
    if cost <= 5.00 then
 
        total := cost
 
        put "You have no sales tax, your meal does not exceed $5.00!"
 
        put "Salestax (0%): $0.00"
 
        put "Tax Total (You do not have a tax): $0.00"
 
 
        put "Grand Total is: $", total
 
        put "*****************************************************"
 
        put "Please enter your amount of cash (Bill or overall change): $" ..
 
        get cash
 
        cash := total - cash
 
        put "***************************************************"
 
        total := cost + salestax
 
        cash := total - cash
 
        if total >= cash then
 
            put " Please give right amound of cash: $", cash - total
 
        elsif cash >= total then
 
            put "Your change is: $", cash - total
 
 
        end if
 
        put "*************************************************"
 
        put "Thanks for Purchasing at ", restuarantName
 
        put "***********************************************"
 
 
 
    elsif cost >= 5 then
 
        salestax := cost * .07
 
        put "You have a sales tax of 7%, your meal exceeds $5.00!"
 
 
 
        put "Salestax (7%): $", salestax : 0 : 2
 
 
        put "Tax Total: $", salestax : 0 : 2
 
        total := cost + salestax
 
        put "Grand Total is: $", total : 0 : 2
 
        put "****************************************"
 
        put "Please enter your amount of cash (Bill or overall change): $" ..
 
        get cash
 
        cash := total - cash
 
        put "************************************************"
 
        total := cost + salestax
 
        cash := total - cash
 
        if total >= cash then
 
            put "Please give right amound of cash: $", cash - total : 0 : 2
 
        elsif cash >= total then
 
            put "Your change is: $", cash - total : 0 : 2
 
            put "Next Customer"
 
            put "Thanks for Purchasing at ", restuarantName
 
            put "*******************************************"
 
 
        end if
 
    end if
 
end loop  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |