Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Need help with one error in java code?
Hi everyone
I am writing a program that calculates the total cost of students' fees and I seem to have one error that I cannot correct. This error is on line 61import java.io.*;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class Tuition
{
public static void main(String[] args);
{
//Declare Variables
int hours;
double fees, rate, tuition;
//Call Methods
displayWelcome();
hours = getHours();
rate = getRate(hours);
tuition = calcTuition(hours, rate);
fees = calcFees(tuition);
displayTotal(tuition + fees);
}
public static void displayWelcome()
{
System.out.println("Welcome to the Tuition and Fees Calculator");
}
public static int getHours()
{
//Declare Variables
String = strHours;
int hours = 0;
//Prompt user for Input
System.out.println("Enter total number of hours used by students");
try
{
hours = Integer.parseInt(strHours);
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"Your entry was invalid.","Error",JOptionPane.INFORMATION_MESSAGE);
{
System.out.println("Please input whole numbers");
}
return hours;
}
public static double getRate(int hours)
{
int hours = 15;
if (hours > 15){
System.out.println("Calculate rate per credit hour");
return rate;
}
else
if(hours<15){
System.out.println("Credit hours are inaccurate");
}
public static double calcTuition(int hours, double rate)
{
//Accept two values
int hours
int rate = 0.0;
int rate * hours;
return tuition;
}
public static double calcFees(double tuition)
{
//Accept double Value
double tuition * 0.8;
double fees
return fees;
}
public static void displayTotal(double total)
{
//Construct DecimalFormat pattern for currency
DecimalFormat Currency = new DecimalFormat("$000.00");
System.out.println("Your total tuition is " fees + tuition);
}
};
};}; :
Error: C:\Course Technology\59850d\Chapter 04\Tuition.java:61: illegal start of expression
public static double getRate(int hours)
^
1 error
Thank You :)
1 Answer
- NunyaLv 79 years agoFavorite Answer
something is wrong with curly braces at least with how yahoo formats questions.
Either:
JOptionPane.showMessageDialog(null… entry was invalid.","Error",JOptionPane.INFORMATIO…
shouldn't have a { after it or you are missing a } after return hours