samedi 25 avril 2015

Very simple calculator?


I'm trying to make a very simple calculator. No GUI yet. The bit I'm stuck on is how to change the user input into numbers that the computer can read and calculate and then print the answer back out. Any help?

import java.util.Scanner;

public class calculator2 {

/**
 * @param args
 */
public static void main(String[] args) {
    Scanner calculation = new Scanner(System.in);
    String calc;
    //application version
    System.out.println("iCalcPro Pre-Alpha");
    //how to use
    System.out.println("Times = *");
    System.out.println("Divide = /");
    System.out.println("Traditional symbols for add and minus.");
    System.out.print("Calculation:");
    calc = calculation.next();
    //print out the input
    System.out.println("Your input: " + calc);
    }
}


Aucun commentaire:

Enregistrer un commentaire