(Java)
Write a program that computes the fare on the New York Transit system given two inputs from the user:
Your prompts to the user must be:
Enter zone number :
Enter adult or child :
The fare on Copenhagen Transit is specified as follows:
Your output must be of the format:
The fare for adultOrChild to zone number zoneNumber is fare.
CODE
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int zoneNumber;
String type;
System.out.print("Enter zone number : ");
zoneNumber = sc.nextInt();
System.out.print("Enter adult or child : ");
type = sc.next();
double fare = -1.00;
if (type.equals("adult")) {
if (zoneNumber <= 3) {
fare = 24.0;
} else if (zoneNumber == 4) {
fare = 34.6;
} else if (zoneNumber == 5) {
fare = 47.0;
} else if (zoneNumber > 5){
fare = -1;
}
} else if (type.equals("child")) {
if (zoneNumber <= 3) {
fare = 11.7;
} else if (zoneNumber == 4 || zoneNumber == 5) {
fare = 22.0;
} else if (zoneNumber > 5){
fare = -1;
}
}
System.out.format("The fare for %s to zone number zoneNumber is %.2f.", type, fare);
}
}
OUTPUT
Enter zone number : 4
Enter adult or child : adult
The fare for adult to zone number zoneNumber is 34.60.
(Java) Write a program that computes the fare on the New York Transit system given two...
o o Write a function, computeFare(), that takes as two parameters: the zone and the ticket type, and returns the Long Island Railroad fare If the zone is 1 and the ticket type is "peak", the fare is 8.75 o If the zone is 1 and the ticket type is "off-peak", the fare is 6.25 o If the zone is 2 or 3 and the ticket type is "peak, the fure is 10.25 If the zone is 2 or3 and...
Write a Java program that prompts the user for the page size used in a virtual memory system; this will be a power of two between 512 (29) and 16384 (214), inclusive. Your program should check the user input for page size to make sure it is one of the allowable inputs (must be a power of 2 and cannot be smaller than 512 or larger than 16384), and should then prompt the user for a virtual address (assume 32-bit...
Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The charge for an adult meal is $6.00 and a child’s (ages 5 to 10) meal is $3.00. The tax rate is 6.5%. The desserts offered at the restaurant are slices of pie at $1.00 per slice. Gratuity is automatically calculated at 15%. Use main( ) as the driver function. Allow the user to process as many customer bills as desired. Use named constants and...
This is a Java program Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number to 2 decimal places. System.out.println(countPositive); System.out.println(countNegative); System.out.println(total); System.out.printf("%.2f",total * 1.0 / count); Assume inputs are always integer [-912985158, 912985158] and ends with 0. Input 1 2 -1 3...
Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and return their total. The main method then prints the digits total with proper label as shown below Method Sum )is of type integer and takes an integer value. The method recursively adds up the digits and returns their total. Document your code and use proper prompts for...
C programming Construct a console program to simulate Zoo ticketing system. The system is used for dispensing tickets to customers. In order to buy tickets, the customer need to enter the following information: a) Number of ticket they want to buy. Everybody must have a ticket to enter. b) Only up to 5 tickets may be purchased for every transaction or customer. c) Type of ticket either for adult, children (aged 5 12 years old) or toddler (aged 2-5 years...
IN SPARC ASSEMBLY ONLY, write a program that prompts the user for two numbers and prints the sum. THIS MUST BE IN SPARC ASSEMBLY. DO NOT WRITE IT IN NORMAL ASSEMBLY LANGUAGE. Sample: Enter Number 1: 2 Enter Number 2: 3 The sum of 2 and 3 is 5 Note: -Your program should contain .data, .bss, and .text sections -DO NOT try to optimize your code (i.e remove nops) -DO NOT write this in regular assembly, it must be in...
Write a java program to solve the problem presented below.You may assune that the user will always enter valid dat;you donot have to perform data validation. The entry charges to a zoo are: Children 5 years old and younger: free Accompanied children from 6 to 15 years old: $2 each Unaccompanied children from 6 to 15 years old.$5 each Adults from 16 to 59 years old:$ 10 each Seniors from 60 years and older:$8 each An accompanied child is defined...
in java
Write an application that: 1. Prompts the user for a number of trials to perform (I will call this "N"). This operation should be type-safe for integers. 2. Simulates N trials of rolling two dice and finding the sum. 3. Uses an array to keep track of how many times each outcome has been rolled (you do not need to keep track of the actual rolls themselves). 4. Computes the percentage of the total number of rolls for...
Please use public class for java. Thank you.
1. (10 points) Write a method that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula futurelnvestmentValue numberOfYears 12 investmentAmount X ( monthlyInterestRate) Use the following method header: public static double futurelnvestmentValue( double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValue 10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user to enter the investment...