Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When i run this code and enter information on out put i get an error. Prof feedback was Your output did not execute but you

When i run this code and enter information on out put i get an error. Prof feedback was "Your output did not execute but you started your program well.The reason your program is giving you an error is because of your format." how may i fix this issue?

import java.text.NumberFormat;

import java.util.Locale;

import java.util.Scanner;

public class Expense {

String name;

double airlinefare,dolltoconvert;

int noofnight;

public static void main(String[] args) {

// TODO Auto-generated method stub

Expense c= new Expense();

c.ask();

c.show();

}

//convert dollar to CUC.

public double convertdollar() {

double pen=dolltoconvert*0.10;

double tax=dolltoconvert*0.03;

return dolltoconvert-(pen+tax);

}

//calculate hotel charge.

public double hotelcharge(){

return noofnight*256.10;

}

//calculate total

public double total() {

return airlinefare +hotelcharge();

}

//display the receipt in well formatted text.

private void show() {

//TODO Auto-generated method stub

Locale locale = new Locale("en", "US");

NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance();

System.out.println();

System.out.printf("%-13s %-1s %-1s " , "", name + " Expense Report", "");

System.out.printf("%-25s %-10s %-5s ","", "Airline Fare", ""+ currencyFormatter.format(airlinefare));

System.out.printf("%-25 %-10s %-5s ","", "Hotel", "=", ""+ currencyFormatter.format(hotelcharge()));

System.out.printf("%-25 %-10s %-5s ", "Total", "=", ""+ currencyFormatter.format(total()));

System.out.printf("%-25s %-10s %-5s ", ""+ currencyFormatter.format(dolltoconvert)+"dollars", "=",

""+currencyFormatter.format(convertdollar())+ "Cuban CUC");

System.out.printf("%-25s %-10s %-5s ","Penalty", "=", "10%");

System.out.printf("%-25s %-10s %-5s ", "Conversion rate", "=", "3%");

}

//ask for input from user

private void ask() {

Scanner sc = new Scanner(System.in);

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

name=sc.next();

System.out.printf("Enter airline fare :$ ");

airlinefare= sc.nextDouble();

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

noofnight=sc.nextInt();

System.out.printf("Enter dollar to convert :$ ");

dolltoconvert=sc.nextDouble();

String nn="";

nn=nn+Character.toUpperCase(name.charAt(0));

for(int i=1;i

nn+=Character.toLowerCase(name.charAt(i));

}

name=nn;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions