Write a Java program to read a 7-digit integer into an int variable named n and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class HW1MansiBhandari public static void mainString args Create a Sca... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Objective (1): Using Stack to match HTML tag in an HTML document, portions of text are delimited by HTML tags. A simple opening HTML tag has the form <name> and the corresponding Closing tag...
-
You have now been asked to work with a textile startup business that your firm has just taken on as a client. The business is particularly in need of support and guidance with budgeting and how it...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A beam of light enters the end of an optic fiber as shown in Fig. 23-52. Show that we can guarantee total internal reflection at the side surface of the material (at point a), if the index of...
-
A re-cooperator is a heat exchanger that heats the air used in a combustion process by extracting energy from the products of combustion (the flue gas). Consider using a single-pass, cross-flow heat...
-
Twin-Cities, Inc., purchased a building for $400,000. Straight-line depreciation was used for each of the first two years using the following assumptions: 25-year estimated useful life, with a...
-
Describe and illustrate the differences among design defects, manufacturing defects, inadequate warnings and labels (marketing defects), and breach of express and implied warranties.
-
The Elixer Drug Company produces a drug from two ingredients. Each ingredient contains the same three antibiotics, in different proportions. One gram of ingredient 1 contributes 3 units, and 1 gram...
-
19. Find the tension T for the system shown in figure :- T T T 1 kg 2 kg 3 kg (1) IgN (2) 2 gN (3) 5 gN (4) 6 gN 20. A ball of mass 0.5 kg moving with a velocity of 2 m/sec strikes a wall normally...
-
1. Which aspect of the French revolution most disturbed commentators? 2. How would you align each of these writers on a spectrum running from extreme right to extreme left in politics? 3. How would...
-
Jamillah deposited RM170,000 into 'Special Investment Account for 9 months period with one of the Islamic bank. During the agad, all the parties are agreed that the predetermined ratio/...
-
When Crocs wanted to increase their sales they used analysis of known behavioural attributes to gain an understanding of their customers and decide on a strategy for contacting them. The resulting...
-
Write a program that assigns seats on an airplane as described in Exercise P12.6 . Keep the seating information in a database. Data from exercise P12.6 Airline seating. Write a program that assigns...
-
In the razor selling business, Gillettes most cut-throat competition is itself. Dominating the market with a reported 85 per cent of sales, Gillette builds on its success with constantly evolving...
-
Design a DTD for invoices, as described in How To 25.3. Data from how to 25.3 Rams 1 3. LESENE 2212 HOW TO 25.3 Writing a DTD You write a DTD to describe a set of XML documents of the same type. The...
-
Recently, a surgical group in Manhattan posted a website that includes a page that refreshes every 10 minutes and shows how close the doctors are following their "scheduled appointment" times. In...
-
Previous Problem (3 points) Match each of the following with the correct statement. C stands for Convergent, D stands for Divergent. 1. 2. 3. 4. 5. 7 n6 - 64 8 + 10" 12 n=1 8+2" In(n) 6n 1 4+ n 7...
-
(a) What is the focal length of a magnifying glass that gives an angular magnification of 8.0 when the image is at infinity? (b) How far must the object be from the lens?
-
The C# compiler always associates an else with the immediately preceding if unless told to do otherwise by the placement of braces ({ and }). This behavior can lead to what is referred to as the...
-
What does the following code display? Console.WriteLine("*"); Console.WriteLine("***"); Console.WriteLine("*****"); Console.WriteLine("****"); Console.WriteLine("**");
-
Explain briefly the operation of each of the following enumerator related methods: a) Get Enumerator b) Current c) Move Next
-
Flaherty Ltd sells two types of shoes, mens shoes and womens shoes. During the financial year ended 30 June 2019, fixed costs were $460 800 and sales were in the ratio of three units (pairs) of mens...
-
Newbery and Newstead is a public accounting firm specialising in auditing local medium-sized businesses. Fees charged for each audit are determined on the basis of identifiable hours worked on an...
-
Hotbox Ltd produces pizza boxes using two processes cutting and packaging. The production budget for the year ending 30 June 2019 estimated raw materials use of $400 000, factory overhead of $270...
Study smarter with the SolutionInn App