Below is a sample JAVA-program for you to analyze. The program below is designed to calculate tuition.
Question:
Below is a sample JAVA-program for you to analyze. The program below is designed to calculate tuition. Based on the current code, the user enters the number of credits and receives an incorrect answer. Review the code below and answer the following.
Based on the current code below, what would the output be if the user entered "6" for the number of credits?
How would you fix the program to give the correct output? (Code Below)
package calcTuition;
//import Scanner
import java.util.Scanner;
public class CalcTuition
{
public static void main(String[] args)
{
//Declare variables
int credits;
final double TUITION_RATE = 100;
double tuitionTotal;
//Get user input
Scanner inputDevice = new Scanner(System.in);
System.out.println("Enter the number of credits: ");
credits = inputDevice.nextInt();
//Calculate tuition
tuitionTotal = credits + TUITION_RATE;
//Display tuition total
System.out.println("You total tuition is: " + tuitionTotal);
}
}
Statistics For Managers Using Microsoft Excel
ISBN: 9780133130805
7th Edition
Authors: David M. Levine, David F. Stephan, Kathryn A. Szabat