Write the java statements as indicated by the comments

Assignment Help Computer Engineering
Reference no: EM131984758

Assignment

In this lab, you complete a partially written Java program that includes a method that returns a value. The program is a simple calculator that prompts the user for two numbers and an operator ( +, -, *, /,or% ). The two numbers and the operator are passed to the method where the appropriate arithmetic operation is performed. The result is then returned to the main() method where the arithmetic operation and result are displayed. For example, if the user enters 3, 4, and *, the following is displayed:

3.00 * 4.00 = 12.00

The source code file provided for this lab includes the necessary variable declarations, and input and output statements. Comments are included in the file to help you write the remainder of the program.

Instructions

Write the Java statements as indicated by the comments.

Execute the program

// Calculator.java - This program performs arithmetic, ( +. -, *. /, % ) on two numbers
// Input: Interactive.
// Output: Result of arithmetic operation

import java.util.Scanner;

public class Calculator
{
public static void main(String args[])
{
double numberOne, numberTwo;
String numberOneString, numberTwoString;
String operation;
double result;
Scanner input = new Scanner(System.in);

System.out.println("Enter the first number: ");
numberOneString = input.nextLine();
numberOne = Double.parseDouble(numberOneString);
System.out.println("Enter the second number: ");
numberTwoString = input.nextLine();
numberTwo = Double.parseDouble(numberTwoString);
System.out.println("Enter an operator (+.-.*,/,%): ");
operation = input.nextLine();

// Call performOperation method here

System.out.format("%.2f",numberOne);
System.out.print(" " + operation + " ");
System.out.format("%.2f", numberTwo);
System.out.print(" = ");
System.out.format("%.2f", result);

System.exit(0);

} // End of main() method.

// Write performOperation method here.

} // End of Calculator class.

Reference no: EM131984758

Questions Cloud

Assume the world is risk-neutral with perfect markets : what is the probability that the bond will pay off in full? Assume the world is risk-neutral with perfect markets.
Estimate how much will you have at the end of ten years : Assume the savings account earns 3.5% compounded annually. If you do as you plan, how much will you have at the end of ten years?
Charged with valuation of hurst company stock : You are charged with the valuation of Hurst Company’s stock. You have access to the following information:
List three to five of the most significant decisions : List three to five of the most significant decisions you have made in your lifetime. To what degree did your emotions play a role in those decisions?
Write the java statements as indicated by the comments : Write the Java statements as indicated by the comments. In this lab, you complete a partially written Java program that includes a method that returns a value.
Compute the coefficient of correlation : HI6007 Group Assignment - Compute the coefficient of correlation and explain the relationship between demand and unit price
Which bank would you go for a new loan : First United Bank charges 11.1% compounded semiannually. As a potential borrower, which bank would you go for a new loan?
Write a program to convert floating point to nearest integer : Write a program to convert floating point to nearest integer, using file input and output. The output should identify both input value and the rounded value.
Market yield and the coupon rate of bond? constant : Holding the market yield and the coupon rate of a bond? constant, as the time to maturity? increases:

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd