Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Trip to Cuba Write a Java program that produces an expense report for your trip

ID: 3722362 • Letter: T

Question

Trip to Cuba Write a Java program that produces an expense report for your trip to Cuba. The program requests your last name and converts the first character to uppercase and the rest of the characters to lowercase. Concatenate the last name with the string "Expense Report" to produce the title of the report. See sample display. The program then accepts the airline fare, the number of nights at the hotel, and the number of dollars you plan to convert to Cuban money. The hotel charges $256.10 per night. The major legal currency for Cuba is the Cuban Convertible Peso, or CUC. It's what you exchange your dollars for and make all your purchases with in Cuba. 1.00 Cuban Convertible Peso = $1.00 USD There is a 10% penalty charged when exchanging US dollars plus a 3% currency exchange fee. You will need to exchange your dollars at the hotel. You cannot use American credit cards or bank cards so take sufficient dollars for the trip. Be sure to test for a variety of values. Here is a sample display with the prompts and results: Expense Input Enter your last name: adaMs Enter airline fare: Enter number of nights: 4 Enter dollars to convert: 150 473.66 Adams Expense Report Airline Fare $473.66 Hotel $1,02440 $1,498.06 Total $150.00 dollars Conversion rate $130.50 Cuban CUC -10% -396 The decimals do not need to align, but align the signs for readability. Purpose of this project: Develop Java program with the following features: Constants and variables o Input data o Calculations including totals o Output display with readable formatting Use the NumberFormat class to format the monetary values and percentages. o String class o The Payroll File in the Chapter Three Activities contains most of the syntax needed. Be sure to comply with Class Standards.

Explanation / Answer

//Program to produce Expense report for your trip to Cuba :

import java.io.*;

import java.util.Scanner;

import java.text.NumberFormat;

import java.text.DecimalFormat;

import java.util.Locale;

class Expense{

public static void main(String[] args){

final double HotelCharge = 256.10;

final int Penulty = 10;

final int ConversionRate = 3;

String LastName;

double AirlineFare, DollersToConvert, Hotel, Total, Cutting, CubanMoney;

int NoOfNights;

Scanner scanner = new Scanner(System.in);

Locale locale = new Locale("-", "-");

NumberFormat numberFormat = new DecimalFormat("00.00");

System.out.println("Expense Input");

System.out.print("Enter your last name: ");

LastName = scanner.nextLine();

System.out.print("Enter airline fare: ");

AirlineFare = scanner.nextDouble();//scanner.nextDouble();

System.out.print("Enter number of nights: ");

NoOfNights = scanner.nextInt();

System.out.print("Enter dollers to convert: ");

DollersToConvert = scanner.nextDouble();//scanner.nextDouble();//numberFormat.format(scanner.nextDouble());

  System.out.println();

System.out.println(LastName.substring(0, 1).toUpperCase() + LastName.substring(1).toLowerCase()+"s Expense Report");

System.out.println("Airline Fare = $"+numberFormat.format(AirlineFare));

Hotel = NoOfNights * HotelCharge;

System.out.println("Hotel = $"+numberFormat.format(Hotel));

Total = Hotel+AirlineFare;

System.out.println();

System.out.println("Total = $"+numberFormat.format(Total));

System.out.println();

Cutting = DollersToConvert * (Penulty+ConversionRate)/100;

CubanMoney = DollersToConvert - Cutting;

System.out.println("$"+numberFormat.format(DollersToConvert)+" dollers = $"+numberFormat.format(CubanMoney)+" Cuban CUC");

System.out.println("Penulty = "+Penulty+"%");

System.out.println("ConversionRate = "+ConversionRate+"%");

}

}

/* Output :

javac Expense.java

java Expense

Expense Input
Enter your last name: AdaMs
Enter airline fare: 473.66
Enter number of nights: 4
Enter dollers to convert: 150
Adamss Expense Report
Airline Fare = $473.66
Hotel = $1024.40

Total = $1498.06

$150.00 dollers = $130.50 Cuban CUC
Penulty = 10%
ConversionRate = 3%

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote