Question: Calculator using Command Line Arguments In this project, youre going to create a Java application called project1.java in which the user will be pass in
Calculator using Command Line Arguments In this project, youre going to create a Java application called project1.java in which the user will be pass in multiple integers separated by spaces at the command line followed by an operator of either + or . When the program runs, you will loop through the strings, convert them to ints using parseInt(String) and based on which operator is passed as the final parameter perform that operation for all of the numbers adding them to a result int. You will display the numbers separated by the operators with an equal sign and the result.
This is the start of the code, I just need it finished.
package icc01;
import java.util.Scanner;
public class project1 { public static void main(String[] args) { int ans=Integer.parseInt (args[0]); char op = args[args.length-1].charAt(0); System.out.print(ans); for(int x=1;x //if op=+ then add to ans else subtract from answer } System.out.println(" = " + ans); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
