Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

Need Help with a basic java program

$
0
0
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





Viewing all articles
Browse latest Browse all 2703

Trending Articles