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)
- Using 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_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_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_forward
- According to researchers at Stanford Medical School, the ideal weight for a woman is found by multiplying her height in inches by 3.5 and subtracting 108. The ideal weight for a man is found by multiplying his height in inches by 4 and subtracting 128. Write a Java program that asks the user for his/her gender, height and weight and responds with the message “You are underweight" or “You are overweight."arrow_forwardWrite 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 the program using javaarrow_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_forwardSubject: Java Programmingarrow_forwardNote: Write a java Program.arrow_forward
- In Java program,,,,,,,,,,,arrow_forwardWrite a program in Java to find the sum of even and odd number between two numbers by getting the input from the user using dialog box a display the sum of even and odd numbers also using dialog boxarrow_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