• 100% Satisfaction Guarantee
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 13425
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
29751445
LogicPro is online now

# Help! I'm very new to java programming and am trying to write

Help!
I'm very new to java programming and am trying to write a code for an assignment but can only get so far. I must produce a Java console application that prompts user to enter child ages and displays cost of travel for the family.(Family consisting of 2 adults and 1 or more children) Adult ticket is 421eurs and a child is under 18. tickets for under 2 cost 25% of adult ticket and under 12 costs 50%, and under 18 75%.The program must prompt user to enter number of children or 0 to exit. Then they are prompted in turn for the number of children under 2 and under 12. The total cost of tickets is to be displayed and breakdown of cost and total child discount. This is as far as I've got:
import java.util.Scanner;
public class ChildDiscount {
public static void main(String[] args) {
// TODO Auto-generated method stub
double childUnder2Discount = 0.75;
double childUnder12Discount = 0.50;
double childUnder18Discount = 0.25;
//Create scanner to read input from keyboard
Scanner scan = new Scanner(System.in);
//Prompt user
System.out.println("Number of Children");
int numKids = scan.nextInt();
// while number of children >0 add number to total
while (numKids > 0){
System.out.println("Number of Children under 2");
int numKidsUnder2 = scan.nextInt();
System.out.println("Number of Children under 12");
int numKidsUnder12 = scan.nextInt();
System.out.println("Number of Children under 18");
int numKidsUnder18 = scan.nextInt();
double grossCostTicketsUnder2 = numKidsUnder2 * adultTicketPrice;
double discountTicketsUnder2 = adultTicketPrice * childUnder2Discount * numKidsUnder2;
double netCostTicketsUnder2 = grossCostTicketsUnder2 - discountTicketsUnder2;
double grossCostTicketsUnder12 = numKidsUnder12 * adultTicketPrice;
double discountTicketsUnder12 = adultTicketPrice * childUnder12Discount * numKidsUnder12;
double netCostTicketsUnder12 = grossCostTicketsUnder12 - discountTicketsUnder12;
double grossCostTicketsUnder18 = numKidsUnder18 * adultTicketPrice;
double discountTicketsUnder18 = adultTicketPrice * childUnder18Discount * numKidsUnder18;
double netCostTicketsUnder18 = grossCostTicketsUnder18 - discountTicketsUnder18;
}
System.out.println("Total");
}
}
OOps, copy and paste makes it look messy. Any help would be appreciated. Mebh.
Customer: replied 2 years ago.
Next wednesday morning!!
Looking at the efforts, I am sending small revised offer. let me know once you accept it.