Question: Write a Java program to read a 7-digit integer into an int variable named n and convert it to another integer stored in an

Write a Java program to read a 7-digit integer into an int

Write a Java program to read a 7-digit integer into an int variable named n and convert it to another integer stored in an int variable named r by changing every digit in n except the first digit as follows: change 3, 6, and 9 to 0 change 4 and 7 to 1 change 5 and 8 to 2. Use the following code to collect your input into the variable n. Don't forget the import statement needed to make the Scanner work. (See Lab 1 code example if you don't remember.) Scanner input = new Scanner (System.in); int n input.nextInt (); If n = 5075498, for instance, the code you write will put 5012102 in r and output "5075498 changed to 5012102" to the user using this Java statement: System.out.println (n+" changed to "+r); Create a Java project named HW1FirstnameLastname using your actual first and last names in NetBeans to hold your program. Additional Assignment Requirements 1. You are only allowed to use 2 integer variables, n and r. 2. You are not allowed to use String methods in the program. 3. You are NOT allowed to use an IF statement or loops. The work of the program must be done using only arithmetic. 4. You may NOT discuss this problem with your classmates. This lab is independent work. Work copied from another student or an online resource will result in enforcement of EKU's Academic Integrity policy as discussed in the syllabus. 5. You must use appropriate spacing, indention, naming conventions, and documentation in your Java program. 6. You will upload your completed work by attaching your HW1Firstname Lastname.java to your submission in Blackboard for the lab assignment. If you need help locating your

Step by Step Solution

3.33 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner public class HW1MansiBhandari public static void mainString args Create a Sca... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!