The following pseudocode describes how to extract the dollars and cents from a price given as a floating-point value. For example, a price 2.95 yields values 2 and 95 for the dollars and cents.
Assign the price to an integer variable dollars.
Multiply the difference price - dollars by 100 and add 0.5.
Assign the result to an integer variable cents.
Translate this pseudocode into a Java
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Starting Out with C++: Early Objects (9th Edition)
Modern Database Management
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Management Information Systems: Managing The Digital Firm (16th Edition)
- Write a program that reads two integers, a and b, from the user. Where a is equal to 17 and b is equal to 4. The program should compute and display the following: i. Sum of a and b. ii. Difference when b is subtracted from a. ii. Result of a. iv. Remainder when a is divided by b.arrow_forwardWrite a java program that prompts the user to enter two integers. The program will compute the quotient of the integers. If the 2d integer is to 0 the program will display "Cannot divide by 0". Use One-way if statement. Analyze the sample output below. Sample Output 1 Enter First Integer: 10 Enter Second Int: 2 The quotient of 10 and 2 is 5 Sample Output 2 Enter First Integer: 13 Enter Second Integers: 0 Cannot divide by 0arrow_forwardUsing Java code: Write a program that is given two integers representing a speed limit and driving speed in miles per hour (mph) and outputs the traffic ticket amount. Driving 10 mph under the speed limit (or slower) receives a $50 ticket. Driving 6 - 20 mph over the speed limit receives a $75 ticket. Driving 21 - 40 mph over the speed limit receives a $150 ticket. Driving faster than 40 mph over the speed limit receives a $300 ticket. Otherwise, no ticket is received.arrow_forward
- LabProgram.java Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to the power of z), the absolute value of y, and the square root of (xy to the power of z). Ex: If the input is: 3.6 4.5 2.0 the output is: 12.96 1.841304610218211E11 4.5 16.2 import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); double x; double y; double z; Answer is supposed to be: 1:Compare outputkeyboard_arrow_up Input 3.6 4.5 2.0 Expected output 12.96 1.841304610218211E11 4.5 16.2 2:Compare outputkeyboard_arrow_up Input -3.7 -3 5 Expected output -693.4395700000001 -8.452419664263233E-139 3.0 410.49459863681534arrow_forwardJava: Write a pseudocode algorithm that gets student exam scores from the user. Each exam score will be an integer in the range 0 to 100. Input will end when the user enters -1 as the input value. After all scores have been read, display the number of students who took the exam, the minimum score, the maximum score, the average score, and the number of As where an A is a score in the range 90-100. Make sure your average a decimal point. Only count A’s, not other grades. Note that you do not need to do any error checking on the input for this problem. This should be done as a standard sentinel-controlled while loop.arrow_forwardWrite a Java program that inputs three numbers, finds their sum and average, and displays the result as Pass or Fail if the average is 60 or above.arrow_forward
- Write a JAVA program that asks the user to input: The number if gallons of gas in the car tank The fuel efficiency in miles per gallon The price of gas per gallon Then (a) print the cost per 100 miles and (b) print how far the car can go with the gas in the tank, (c) Assuming the gas tank capacity is 20 gallons, what will be the cost of adding gas to the existing amount to fill the tankarrow_forwardWrite a program that asks the user to enter a month (1 for January, 2 for February, etc.) and thenprints the number of days in the month. For February, print “28 days”.Enter a month: 530 days Note : Solve this by using javaarrow_forwardWrite a program in python Suppose a right triangle is placed in a plane as shown below. The right-angle point is at (0, 0), and the other two points are at (200, 0), and (0, 100). Write a program that prompts the user to enter a point with x- and y-coordinates and determines whether the point is inside the triangle. Sample runs of the program are given below: Enter a point's x- and y-coordinates: 100.5 25.5 The point is in the triangle Enter a point's x- and y-coordinates: 100.5 50.5 The point is not in the trianglearrow_forward
- 1. Write a Java program to input an integer then print its ones digit. 2. Write a Java program that would input a 3-digit integer then display its a) leftmost digit only b) middle digit only c) rightmost digit only 3.Write a Java program to print all natural numbers from 1 to n. - using while loop 4.Write a Java program to print all natural numbers in reverse (from n to 1). - using while loop 5.Write a Java program to print all alphabets from a to z. - using while loop, hint use ASCII characters 6. Write a Java program to print all even numbers between 1 to 100. - using for loop 7.Write a Java program to print all odd number between 1 to 100. - using do...while 8.Write a Java program to find sum of all natural numbers between 1 to n. - using do...while 9. Write a Java program to find sum of all even numbers between 1 to n. - using while loop 10.Write a Java program to find sum of all odd numbers between 1 to n. - using while loop itsarrow_forwardThe volume of oil stored in an underground 200-foot-deep cylindrical tank is determined by measuring thedistance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank thevolume of oil in the tank can be determined using the formula:volume = π × radius2 × (200 − distance)Using this formula, write a JAVA program that accepts the radius and the distance measures, calculates thevolume of the oil in the tank, and displays the two input values and calculates the volume.arrow_forwardPeople find it easier to read time in hours, minutes, and seconds rather than just seconds. Write a program that reads in seconds as input, and outputs the time in hours, minutes, and seconds. Ex: If the input is: 4000 the output is: Hours: 1 Minutes: 6 Seconds: 40 NOTE: Write in Java language!arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr