FOR the time being, i modified code to make it much simpler as i couldn't figure out what i wanted to do lol
so here's the temporary working code:
Code
package com.example.test;
import java.util.Scanner;
public class Main {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Calculator program starting....");
System.out.println("Choose which numbers to operate on: ");
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
scanner.nextLine();
printOptions();
System.out.println("Choose your option: ");
int option = scanner.nextInt();
switch (option) {
case 1:
System.out.println("You have chosen addition, " + num1 + " will be added to " + num2);
System.out.println("Your answer is: " + (num1 + num2));
break;
case 2:
System.out.println("You have chosen subtraction, " + num1 + " will be subtracted from " + num2);
System.out.println("Your answer is " + (num1 - num2));
break;
case 3:
System.out.println("You have chosen multiplication, " + num1 + " will be multiplied by " + num2);
System.out.println("Your answer is " + (num1 * num2));
break;
case 4:
System.out.println("You have chosen division, " + num1 + " will be divided by " + num2);
System.out.println("Your answer is " + (num1 / num2));
break;
}
}
public static void printOptions() {
System.out.println("List of options: \n" +
"1: for addition \n" +
"2: for subtraction \n" +
"3: for multiplication \n" +
"4: for division \n");
}
}
BUT, what i'd like to do, is add a feature to operate on multiple numbers.....(more then 2)
and going off user input to determine how many elements to operate on... not sure how to go about this though.
If anyone has any hints, that would be awesome
This post was edited by ferf on Jun 11 2019 07:23pm