How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask LogicPro Your Own Question

LogicPro
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 12551
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
29751445
Type Your Programming Question Here...
LogicPro is online now

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

Customer Question

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 adultTicketPrice = 421.00;
double childUnder2Discount = 0.75;
double childUnder12Discount = 0.50;
double childUnder18Discount = 0.25;
int numAdults = 2;
//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 costAdultTickets = numAdults * adultTicketPrice;
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.
Submitted: 1 year ago.
Category: Programming
Expert:  LogicPro replied 1 year ago.
Hi,What is the deadline?
Customer: replied 1 year ago.
Next wednesday morning!!
Expert:  LogicPro replied 1 year ago.
Looking at the efforts, I am sending small revised offer. let me know once you accept it.
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 12551
Experience: Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
LogicPro and 2 other Programming Specialists are ready to help you
Expert:  LogicPro replied 1 year ago.
thank you.Please check back in few hours for the answer.
Customer: replied 1 year ago.
A few hours??? ok.
Expert:  LogicPro replied 1 year ago.
10-12 hours
Customer: replied 1 year ago.
ok thanks
Expert:  LogicPro replied 1 year ago.
welcome
Expert:  LogicPro replied 1 year ago.
Here is working code:http://pastebin.com/raw/ckg0DScf Please consider adding bonushttp://ww2.justanswer.com/help/what-if-expert-does-really-fantastic-job-hl\ You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers. It will ensure that question is for me.Please bookmark my profile page:http://www.justanswer.com/homework/expert-logicpro/so you can come back and ask me a question anytime. Thank you for using this site! LogicPro
Customer: replied 1 year ago.
For LogicPro
Thank you!!! The program works wonderfully.
Mebh
Expert:  LogicPro replied 1 year ago.
Thank you

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
< Previous | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.
 
 
 

Meet The Experts:

 
 
 
  • ATLPROG

    ATLPROG

    Computer Software Engineer

    Satisfied Customers:

    7260
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
< Previous | Next >
  • http://ww2.justanswer.com/uploads/SP/spatlanta2010/2011-6-23_12450_photo.64x64.gif ATLPROG's Avatar

    ATLPROG

    Computer Software Engineer

    Satisfied Customers:

    7260
    MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Computer Software Engineer

    Satisfied Customers:

    5514
    Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
  • http://ww2.justanswer.com/uploads/lifesaver333/2010-10-17_191349_ls.jpeg lifesaver's Avatar

    lifesaver

    Computer Software Engineer

    Satisfied Customers:

    936
    Several years of intensive programming and application development experience in various platforms.
  • http://ww2.justanswer.com/uploads/EH/ehabtutor/2012-8-2_202016_1.64x64.jpg ehabtutor's Avatar

    ehabtutor

    Computer Software Engineer

    Satisfied Customers:

    766
    Bachelor of computer science, 5+ years experience in software development, software company owner
  • http://ww2.justanswer.com/uploads/eljonis/2010-01-06_130406_eljon2.jpg Eljon's Avatar

    Eljon

    Consultant

    Satisfied Customers:

    558
    Founder of StockCanvas.com
  • http://ww2.justanswer.com/uploads/FA/fael/2011-1-15_104041_profile500x500.64x64.jpg Rafael Martins's Avatar

    Rafael Martins

    Computer Software Engineer

    Satisfied Customers:

    446
    Desktop, Mobile and Web Developer. 7+ years of experience. Creative solutions provider.
  • http://ww2.justanswer.com/uploads/CH/chutz747/2011-11-6_14231_me.64x64.jpg The-PC-Guy's Avatar

    The-PC-Guy

    Software Engineer

    Satisfied Customers:

    320
    Extensive Knowledge in PHP, MYSQL, CSS & Javascript