Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Statistics For Managers Using Microsoft Excel

Authors: David M. Levine, David F. Stephan, Kathryn A. Szabat

7th Edition

978-0133061819, 133061817, 978-0133130805

More Books

Students also viewed these Programming questions

Question

18. What are some of the privacy issues that Facebook has created?

Answered: 1 week ago

Question

1. What is change blindness?

Answered: 1 week ago