Hi guys,
I'm new at Java, but I'm new and learning fast. I brought a book of Amazon called 'Java for Dummies' by Barry Burd, I recommend this book, it is easy to read and well explained. I am willing to learn alot about Java, hoping to be able to orientate myself to Android application development. I speak english and french fluently, though I don't think french will help alot here
I have written very little thing so far in Java, including a simple calculator (no gui) and a couple of other various thing. I'm new to all this, but I'm motivated.
The first thing I'm gonna ask is:
-Is this good for my first code ever in Java?
import static java.lang.System.in; import static java.lang.System.out; import java.util.Scanner; public class calculatorCore { public static void main(String[] args) { Scanner input = new Scanner(in); boolean realAnswerMenu = false; out.println("------ extremeCalc by " + info.creatorName + "------"); out.println(); out.println("Menu-------------------------------"); out.println("-- 1 - Calculate now! -------------"); out.println("-- 2 - Info -----------------------"); out.println("-----------------------------------"); out.println(); do { out.print("MENU > "); String menu = input.next(); try { int menuInt = Integer.parseInt(menu); out.println(); switch (menuInt) { case 1: realAnswerMenu = true; break; case 2: out.println("Simple, just type what your asked, and press [ENTER], if you want to stop, when they ask you a sign type stop and fill the input spaces with random ints until it stops, uppercase or lowercase does not matter."); out.println("Made by " + info.creatorName); out.println("Build " + info.build + " "+ info.versionName); out.println(); break; default: out.println("Sorry, dunno that option, enter a number depending what you want and press [ENTER]"); out.println(); } } catch (NumberFormatException e) { out.println(); out.println("Sorry, dunno that option, enter a number depending what you want and press [ENTER]"); out.println(); } } while (realAnswerMenu == false); out.println(); String sign; double num; out.print("NUM > "); double tot = input.nextDouble(); boolean stop = false; do { do { out.print("SIGN > "); sign = input.next(); if (!sign.equalsIgnoreCase("stop") && !sign.equals("-") && !sign.equals("+") && !sign.equals("*") && !sign.equals("/")) { out.println("ERROR> Sign not recognised"); } if (sign.equalsIgnoreCase("stop")) { stop = true; } } while (!sign.equalsIgnoreCase("stop") && !sign.equals("-") && !sign.equals("+") && !sign.equals("*") && !sign.equals("/")); out.print("NUM > "); num = input.nextDouble(); if (sign.equals("+")) { tot = calculations.addition(tot , num); } if (sign.equals("-")) { tot = calculations.subtraction(tot , num); } if (sign.equals("*")) { tot = calculations.multiplication(tot , num); } if (sign.equals("/")) { tot = calculations.division(tot , num); } out.println("TOTAL> " + tot); } while (stop != true); out.print("Thanks HF for using my calculator :D, " + info.creatorName); } }public class calculations { public static double addition(double tot , double num) { return tot += num; } public static double subtraction(double tot , double num) { return tot -= num; } public static double multiplication(double tot , double num) { return tot *= num; } public static double division(double tot , double num) { return tot /= num; } }Please give me tips to make it better.public class info { static int build = 1; static String versionName = "0.1 ALPHA"; static String creatorName = "zeokila"; }