Write a program that reads in two floating-point numbers and

Assignment Help Basic Computer Science
Reference no: EM13234927

Write a program that reads in two floating-point numbers and tests whether they are the same up to two decimal places. here are two sample runs. Enter two floating-point numbers: 2.0 1.99998 They are the same up to two decimal palces. Enter two floating-point numbers: 2.0 1.98999 They are different. import java.util.Scanner; class FloatingPoint { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter two floating-point numbers: "); double x = sc.nextDouble(); double y = sc.nextDouble(); if (x== y) System.out.println("They are the same up to two decimal places."); else System.out.println("They are different"); } } This is the code I have come up with so far which i know is incorrect. I need help writing the code that checks these numbers up to two decimal places to see if they are the same or different.

Reference no: EM13234927

Questions Cloud

Which dim statement would correctly declare an array : Which Dim statement would correctly declare an array of this structure for elements having subscripts from 0 through 30
What is the marginal cost of producing 2 units of output : An accountant for a car rental company was recently asked to report the firm's costs of producing various levels of output. The accountant knows that the most recent estimate available of the firm's cost function is, C(Q)=100+10Q+Q^2
What is the magnitude of its velocity : A flight controller determines that an airplane is 30.0mi south of him, Half an hour later the same plane is 30.0mi north west of him, What is the magnitude of its velocity during this time
Calculate the marginal product of labor when 9units utilised : The manager of a national retailing outlet recently hired an economist to estimate the firm's production function. Based on the economist's report, the manager now knows that the firm's production function is given by Q=K^(1/2) L^(1/2)
Write a program that reads in two floating-point numbers and : Write a program that reads in two floating-point numbers and tests whether they are the same up to two decimal places. here are two sample runs.
What is constitutional protection against double jeopardy : What is Constitutional protection against double jeopardy?
What constitutional amendment are they derived from : What are your Miranda Rights and what Constitutional Amendment are they derived from? When do they apply?
Find what is the marginal product of capital and labor : The manager of a meat-packing plant can use either butchers (labor) or meat saws (capital) to prepare packages of sirloin steak. Based on estimates provided by an efficiency expert, the firm's production function for sirloin steak is given by Q=K+..
Describe the constitutional protection against unreasonable : Describe the Constitutional protection against unreasonable search and Discuss the Federal antiterrorism Act briefly.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explain how engineers be assigned to maximize sales

A sales manager has 3 areas and 5 sales engineers. If assignment of sales engineers to areas will result in expected sales as shown, how must engineers be assigned to maximize sales?

  Explain why its difficult to support direct assess to files

explain why its difficult to support direct assess to files with variable length records. suggest a method for handling this type of file if direct access is required.

  Which of the following baseband technologies

The IEEE 802.3u standard identifies which of the following baseband technologies

  Write and explain the definition of composition in c++

Write and explain the definition of composition in C++ and how it is useful in writing object-oriented programming. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriente..

  How each room is identified by a room number

Each resident patient will stay in only one room. Every room must have had a patient, and every resident patient must have a room.

  Write a program that prompts the user to input a string

Write a program that prompts the user to input a string and then outputs the string in the pig Latin form. The rules for converting a string into pig latin form are described in Programming example : Your program must store the characters of a str..

  Company officers to find which planning approach is suitable

If you were in charge of systems planning for a small firm, what questions would you ask the company officers to determine which planning approach would be the most appropriate.

  What is capacity with two shifts

Given the following data for Albert's fabricating production area:Fixed costs for one shift = $60,000. What is the capacity with two shifts? The additional fixed cost for a second shift is $40,000.

  How implement memory allocation with strings

how implement memory allocation with strings.

  What are the advantages of using variables in a data type

A data type describes the format and size of a data item. However, it does not define the type of operation a data item needs to perform. Do you agree with this statement

  The ieee 754 single precision binary representation

What would be the IEEE 754 single precision binary representation of the floating point value -314159265. 3589 ? Express your final answer as an 8-hex-digit number and explain how your answer was obtained for full credit.

  Using sequential logic, counters and shift registers propose

using sequential logic, counters and shift registers propose a more complex system utilizing some of the more complex sub systems. example a motion acitavated light. Needs to be somthing other then a light example like motors or somthing

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