Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem b (PA2b.java) Write a program to do the reverse of Problem a. It prompts

ID: 3746884 • Letter: P

Question

Problem b (PA2b.java) Write a program to do the reverse of Problem a. It prompts the user for a length in inches, then converts that total number of inches into yards, feet, and inches. Note that you do not convert the number of inches separately into yards, then feet, then inches. Instead the program must calculate how many yards there are in the given number of inches, then convert the remaining inches into feet, and finally have the left over inches directly. For example, if the user enters 50 for the total number of inches, your program should compute the result that is equal to 1 yard, 1 foot, and 2 inches. The following represents a run of the program using this sample input (again, pay very careful attention to spacing, spelling, and capitalization). Enter number of inches: 50 Yards: 1 Feet: 1 Inches: 2

Explanation / Answer

import java.util.Scanner; public class PA2b { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter number of inches: "); int inches = in.nextInt(); int yards = inches / 36; inches %= 36; int feet = inches / 12; inches %= 12; System.out.printf("%d yards, %d feet and %d inches ", yards, feet, inches); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote