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
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);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started