Question: Lab Exercise 5.4 Instructions: Code a program using the methods you created in LE 5.3. Use the sample output (below) to determine the logic of

Lab Exercise 5.4 Instructions: Code a program using the methods you created in LE 5.3. Use the sample output (below) to determine the logic of your method calls in the main(). Consider the following:

Re-read LE 5.3 instructions to determine the fields.

Use the data in the sample output to test your LE 5.4.

Call the overloaded tickets method as an argument in the method coded in 1c of LE 5.3.

Call the method coded in 1d of LE 5.3 in the printf statement that prints the final output. E.g.:method1(method2(arg1, arg2), method3(arg1));

Name the program as YourLastNameFirstInitialLE54.java.

Sample Output:

***ON-BUDGET***

Enter your yearly entertainment budget: 190.80

Enter the number of tickets to be purchased: 2

YEARLY FUN FOR ALVIN

Yearly Fun Cost: $190.80

Yearly Budget: $190.80

Just the right fun! On-budget!

***OVER-BUDGET***

Enter your yearly entertainment budget: 84

Enter the number of tickets to be purchased: 2

YEARLY FUN FOR ALVIN

Yearly Fun Cost: $190.80

Yearly Budget: $84.00

Way too much fun! Over-budget!

***UNDER-BUDGET***

Enter your yearly entertainment budget: 200

Enter the number of tickets to be purchased: 1

YEARLY FUN FOR ALVIN

Yearly Fun Cost: $95.40

Yearly Budget: $200.00

Little more fun! Under-budget!

This is what I have so far:

import java.util.Scanner;

public class AlvaradoJLE54 { private static Scanner input=new Scanner(System.in); public static void main(String[]args) { budget(); tickets(); myFun(tickets(), budget()); System.exit(0); }//End of main public static double budget() { System.out.printf("%nEnter your yearly entertainment budget: "); return input.nextDouble(); }//End double budget. public static int tickets() { System.out.printf("%nEnter number of tickets to be purchased: "); return input.nextInt(); }//End void tickets. public static double tickets(int totalTickets, double price) { int tickets = totalTickets; price = 95.40; return totalTickets * price; public static void myFun(double yearlyFun, double yearlyFunBudget) { yearlyFun = tickets(); yearlyFunBudget = budget();

System.out.printf("%n%nYEARLY FUN FOR ALVIN%n" +"Yearly Fun Cost: %d" +"Yearly Budget: %d",yearlyFun, yearlyFunBudget); if(yearlyFun > yearlyFunBudget) System.out.printf("Way too much fun! Over-budget!"); else if(yearlyFun < yearlyFunBudget) System.out.printf("Little more fun! Under-budget!"); else System.out.println("Just the right fun! On-budget!"); }//End void myFun }//End Application

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!