
I got a little question. I was doing this coding problem which is really easy. Basically u gota draw a calculator that can add to numbers. You draw the calculator in the promt so u dont need any GUI.
here is the code:
Code: Select all
import java.util.Scanner; //Needed for the scanner class
public class Calculator
{
public static void main (String[]args)
{
double num_1; //declare number 1
double num_2; //declare number 2
double SUM; //declare the SUM
Scanner kbd = new Scanner(System.in);
num_1 = kbd.nextDouble();
num_2 = kbd.nextDouble();
SUM = num_1 + num_2;
System.out.println(" --------------------- ");
System.out.println(" | ---------------- | ");
System.out.printf (" | |%14d | |\n", SUM );
System.out.println(" | ---------------- | ");
System.out.println(" | | ");
System.out.println(" | 7 8 9 + | ");
System.out.println(" | | ");
System.out.println(" | 4 5 6 - | ");
System.out.println(" | | ");
System.out.println(" | 1 2 3 * | ");
System.out.println(" | | ");
System.out.println(" | 0 = / | ");
System.out.println(" | | ");
System.out.println(" --------------------- ");
}
}
The only line that doesnt work is this one:
Code: Select all
System.out.printf (" | |%14d | |\n", SUM );
But it gives me an error. I am doing this on windows java, while in class its in linux and the teacher said you might have problems if u dont do it on linux machine... But i dont know if thats the problem. tx
ps(its due 2ow)[/code]