Debug the code provided in the starter file. This program is supposed to print Ratio OK...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Debug the code provided in the starter file. This program is supposed to print "Ratio OK" if the ratio of two integers entered by the user is between 1 exclusive and 8 inclusive (i.e. if the first divided by the second is greater than 1 and less than or equal to 8). The debugged code should not produce any error messages as long as two integers are entered by the user. Although the program asks the user to scan in two integer values using the nextInt() method, make sure to declare one variable as a double so the ratio of the two integers will produce a double result instead of an integer result. Files U3_L5_Activity_One.java STATUS 12345678 /* Lesson 5 Coding Activity Question 1 */ 3 import java.util.Scanner; 5 public class U3_L5_Activity_One 6 - { 8- 9 10 11 NOT SUBMITTED 12 13 14 15 16 17 18 19 18 } public static void main(String[] args) { } Scanner scan = new Scanner(System.in); System.out.println("Enter 2 integers:"); int x = scan.nextInt(); scan.nextDouble(); int y if(x/y< 8 && x != 0) System.out.println("Ratio OK"); SAVE SUBMIT V= V= INSTRUCTIONS RUN CODE GRADING KX KY HISTORY Debug the code provided in the starter file. This program is supposed to print "Ratio OK" if the ratio of two integers entered by the user is between 1 exclusive and 8 inclusive (i.e. if the first divided by the second is greater than 1 and less than or equal to 8). The debugged code should not produce any error messages as long as two integers are entered by the user. Although the program asks the user to scan in two integer values using the nextInt() method, make sure to declare one variable as a double so the ratio of the two integers will produce a double result instead of an integer result. Debug the code provided in the starter file. This program is supposed to print "Ratio OK" if the ratio of two integers entered by the user is between 1 exclusive and 8 inclusive (i.e. if the first divided by the second is greater than 1 and less than or equal to 8). The debugged code should not produce any error messages as long as two integers are entered by the user. Although the program asks the user to scan in two integer values using the nextInt() method, make sure to declare one variable as a double so the ratio of the two integers will produce a double result instead of an integer result. Files U3_L5_Activity_One.java STATUS 12345678 /* Lesson 5 Coding Activity Question 1 */ 3 import java.util.Scanner; 5 public class U3_L5_Activity_One 6 - { 8- 9 10 11 NOT SUBMITTED 12 13 14 15 16 17 18 19 18 } public static void main(String[] args) { } Scanner scan = new Scanner(System.in); System.out.println("Enter 2 integers:"); int x = scan.nextInt(); scan.nextDouble(); int y if(x/y< 8 && x != 0) System.out.println("Ratio OK"); SAVE SUBMIT V= V= INSTRUCTIONS RUN CODE GRADING KX KY HISTORY Debug the code provided in the starter file. This program is supposed to print "Ratio OK" if the ratio of two integers entered by the user is between 1 exclusive and 8 inclusive (i.e. if the first divided by the second is greater than 1 and less than or equal to 8). The debugged code should not produce any error messages as long as two integers are entered by the user. Although the program asks the user to scan in two integer values using the nextInt() method, make sure to declare one variable as a double so the ratio of the two integers will produce a double result instead of an integer result.
Expert Answer:
Answer rating: 100% (QA)
Corrected code with debugging java import javautilScanner public class U3L5Acti... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
A 5 0 0 kg milk truck is moving west at 1 2 m / s . At the same time, a 6 kg tricycle is being driven at 6 5 deg N of E with a velocity of 1 5 m / s . The two vehicles collide and become fused...
-
Write a char-converter program that accepts a single line of text from the user and converts Turkish characters to English ones. Check the text character by character using a for-loop. Sample...
-
John Fleming, chief administrator for a district hospital, is concerned about costs for tests in the hospital's lab. Fleming has asked you to evaluate costs for the past month. The following...
-
The following data represent the square footage and rents (dollars per month) for apartments in the La Jolla area of San Diego, California. (a) Using a graphing utility, draw a scatter plot of the...
-
Susan Cashin Company identifies the following items for possible inclusion in the physical inventory. Indicate whether each item should be included or excluded from the inventory taking. (a) 900...
-
Iodide ion is oxidized by hypochlorite ion in basic solution. I(aq) + ClO(aq) Cl(aq) + IO(aq) In 1.00 M NaOH at 25oC, the iodide-ion concentration (equal to the ClO concentration) at different times...
-
Which of these is an inertial reference frame (or a very good approximation)? A. Your bedroom B. A car rolling down a steep hill C. A train coasting along a level track D. A rocket being launched E....
-
Sym Corporation, a wholly owned subsidiary of Paratec Corporation, leased equipment from its parent company on August 1, 2016. The terms of the agreement clearly do not require the lease to be...
-
What strategy has been found to be particularly helpful for keeping teams together?
-
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...
-
You are looking to purchase a new home that is listed at $315,100. You have saved enough to make a 20% downpayment, so the loan amount will be 80% of the purchase price. You are talking to a lender...
-
Assume we have a PLAM for $450,000 mortgage with a 30 year term and monthly payments. The "real" loan rate is 3%, with inflation rates of 3, 4, and 5% for years 1, 2, 3, respectively. What is the...
-
There are 4 types of products and services. Non-Inventory Items: Non-inventory items are products you buy or sell but do not considered inventory. Inventory Items: Inventory items are items to be...
-
} ) 5. Identify what each of the following methods of the subclass do: override, hide, overload or cause a compiler error. public class ClassA { public void methodOne (int i) () public void...
-
Assume we have a $500,000 mortgage at 3.5% original interest rate, with a 30- year term and monthly payments. The interest rate can be adjusted at the end of each year, and we assume the rate...
-
Find the following: (a) In(e) (b) In(e e5) (c) In((e)4)
-
lan operates an automobile repair shop and he has the opportunity to buy an additional machine, which he needs to continue servicing his increasing customer base, at a bargain price of $6,200 if he...
-
3M Company reports the following financial statement amounts in its 10-K report: a. Compute the receivables, inventory, and PPE turnover ratios for both 2018 and 2017. (Receivables turnover and...
-
Steve Jackson (age 51) is a single taxpayer living at 3215 Pacific Dr., Del Mar, CA 92014. His Social Security number is 465-88-9415. In 2012, Steve's earnings and income tax withholding as the...
-
Olive Corporation was formed and began operations on January 1, 2012. The corporation's income statement for the year and the balance sheet at year-end are presented below. The corporation made...
-
Your supervisor has asked you to research the following situation concerning Owen and Lisa Cordoncillo. Owen and Lisa are brother and sister. In May 2012, Owen and Lisa exchange business pickup...
-
1. An analyst estimates that a securitys intrinsic value is lower than its market value. The security appears to be: A. Undervalued. B. Fairly valued. C. Overvalued. 2. A market in which assets...
-
The expected effect on market efficiency of opening a securities market to trading by foreigners would be to: A. Decrease market efficiency. B. Leave market efficiency unchanged. C. Increase market...
-
Suppose that a speculative-grade bond issuer announces, just before bond markets open, that it will default on an upcoming interest payment. In the announcement, the issuer confirms various reports...
Study smarter with the SolutionInn App