Scanner Java Class
Hi,
I have a Java JDK 1.6.0.13 on Windows XP and on Ubuntu 9.04, but a program that use a Scanner Java Class run correct on Windows XP and do not run correct on Ubuntu.
Above i wrote the program and the error. Can you help me ?
Thanks,
Jorge Elias
My program:
import java.util.Scanner;
public class InvoiceApp
{
public static void main (String[] args)
{
Scanner sc = new Scanner (System.in); // create a new instance of Scanner class
double subtotal, discountPercent, discountAmount, invoiceTotal;
String message;
// display a welcome message
System.
System.
// get the input from the user
System.
subtotal = sc.nextDouble ();
// calculate the discount amont and total
discountPercent = .2;
discountAmount = subtotal * discountPercent;
invoiceTotal = subtotal - discountAmount;
// format and display the result
message = "Discount percent: " + discountPercent + "\n" +
"Discount amount : " + discountAmount + "\n" +
"Invoice total : " + invoiceTotal + "\n";
System.
}
}
The error:
>javac InvoiceApp.java
>Exit code: 0
>java InvoiceApp
Welcome to the Invoice Total Calculator
Enter subtotal:
Exception in thread "main" java.util.
at java.util.
at java.util.
at java.util.
at InvoiceApp.
>Exit code: 1
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Jorge Elias for more information if necessary.