So i made a calc a while ago ,
now im trying to chance some stuff , instead of using 3 scanners i need it to use 1 only but really cant figure out how :S
and at the end of the code where it asks the user for J to continue and N to finish i want to put that in a Do while loop but its not working any help is appreciated!
Code atm looks like this användarInlägg is = userinput , and yes im new to this
boolean status=true;
while (status){
Scanner minScanner1 = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
System.out.println("Skriv in ditt nummer en och en :\n");
double nr1 = minScanner1.nextDouble();
double nr2 = minScanner1.nextDouble();
System.out.println("välj vad du vill göra: ");
double svr =0;
String användarInlägg = scanner2.nextLine();
if(användarInlägg.equalsIgnoreCase("+")) {
svr = nr1 + nr2;
}
else if(användarInlägg.equalsIgnoreCase("-")) {
svr = nr1 - nr2;
}
else if(användarInlägg.equalsIgnoreCase("*")) {
svr = nr1 * nr2;
}
else if(användarInlägg.equalsIgnoreCase("/")) {
svr = nr1 / nr2;
}
System.out.printf("= %.2f\n ", svr);
System.out.println("Skriv in J för att fortsätta N för att sluta: \n");
Scanner scanner3 = new Scanner(System.in);
String input=scanner3.nextLine();
do{
}while(input.equalsIgnoreCase("J"));
if (input.equalsIgnoreCase("N")) {
System.exit(0);
} else if (input.equalsIgnoreCase("J")) {
status = true;
}
}
}
}