Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions