Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need Help with a basic java program Posted by damo1982 on 20 Nov 2012 at 6:19 AM
Hi I recently got a new assignment from college and am unable to complete and was hoping someone here could help me we have to basically set up a ticket machine where you input name of show name of person how many in the booking if theres is over 6 in the booking you get a 10% discount and at the end you have to input y or n for the program to restart i have worked out most of the program except for the last couple of lines for the do while loop if someone could please show me where I am going wrong it would be much appreciated

class project //class(name of program)
{
public static void main(String[] args) //main method to be included in all programs
{
int numberpeople, cost, ticketcost, discount, discountcost;
String surname, nameofshow;
char awnser;
ticketcost = 25;

do
{
System.out.println("Hello What is the surname the booking was made under");
surname = EasyIn.getString();

System.out.println("What is the name of the show you wish to see");
nameofshow = EasyIn.getString();

System.out.println("How many people are in your party");
numberpeople = EasyIn.getInt();


System.out.println("*******************************Tickets Printout********************************");
System.out.println(" Show : " + nameofshow);
System.out.println(" Surname : " + surname);
System.out.println(" No.In Party : " + numberpeople);


{
cost=(numberpeople*ticketcost);
discount =(cost/100*10);
discountcost =(cost-discount);

if(numberpeople>=6);
cost =(ticketcost*numberpeople);
discountcost=(cost-discount);
System.out.println(" Cost : " + discountcost);

if(numberpeople<=5);

cost =(ticketcost*numberpeople);
System.out.println(" Cost : " + cost);

}


System.out.println("Would you like to print another ticket Please awnser only with lowercase (y/n)?");
awnser=EasyIn.getChar();
if (awnser=='y') System.out.println("Please wait for the program to restart");
if (awnser=='n')System.out.println("Have a nice day");
else if System.out.println("Invalid Selection");
}
while ((awnser !='y')&&(awnser='n'));

}
} //end of program







 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.