Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) else System.out.println("Positive."); System.out.println("Non-positive, converting to 1. "); userNum = 1; System.out.println("Final: + userNum); Common student error: Changing the order of the lines. You only need to fix the existing code. 1 import java.util.Scanner; 2 7689SSDWNA 3 public class ConvertNegative { 4 public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int userNum; 5 10 11 TTT TIL 12 13 System.out.println("Non-positive, 14 56700 userNum = 1; 15 System.out.println("Final: 16 17 userNum scnr.nextInt (); if (userNum > 0) System.out.println("Positive."); 18 } else } converting to 1."); + userNum); /* Your solution goes here */ Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) else System.out.println("Positive."); System.out.println("Non-positive, converting to 1. "); userNum = 1; System.out.println("Final: + userNum); Common student error: Changing the order of the lines. You only need to fix the existing code. 1 import java.util.Scanner; 2 7689SSDWNA 3 public class ConvertNegative { 4 public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int userNum; 5 10 11 TTT TIL 12 13 System.out.println("Non-positive, 14 56700 userNum = 1; 15 System.out.println("Final: 16 17 userNum scnr.nextInt (); if (userNum > 0) System.out.println("Positive."); 18 } else } converting to 1."); + userNum); /* Your solution goes here */
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below Answer Here is the correcte... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Recall that simple linear regression was used to model y = mass of the spill as a function of x = elapsed time of the spill. a. Find a 99% confidence interval for the mean mass of all spills with an...
-
import java.sql.*; public class TestJDBC { public static void main(String[] args) { try { Driver d = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); System.out.println(d);...
-
Student 2 comes to class with probability 1.0 if student 1 does. Student 3 ignores them. A small class has only three students. Each comes to class with probability 0.9. Find the probability that all...
-
Use the following information to answer the questions that follow.... The Big Cheese Company * 2019 2020 Interest Expense 200 1950 Cash 180 30 Property, Plant, and Equipment 16000 39550 Inventories...
-
Woo Financial Services Declared dividends of $1 today. Dividends are expected to remain the constant for 3yrs. After year 3 dividends are expected to grow 5% for 2yrs, 15% for 3yrs after which settle...
-
In each of the following, calculate the exact value of tan x. a. tan (x 45) = 1/4 b. sin (x 60) = 3 cos (x + 30) c. tan (x 60) = 2
-
An airline manufacturer incurred the following costs last month (in thousands of dollars): Requirements: 1. Assuming the cost object is an airplane, classify each cost as one of the following: direct...
-
Recent balance sheet information for two companies in the food industry, H.J. Heinz Company and the Hershey Company, is as follows (in thousands of dollars): a. Determine the ratio of liabilities to...
-
A 20N force acts perpendicular to the door 0.8m wide at its edge. Find moment at hinges. Also find moment at hinges if 20N force acts at 60 with the plane of door. i) 20N force acting perpendicular...
-
You work for Euroc, a limited liability company, which seeks growth through acquisitions. You are a member of a team that is investigating the possible purchase of Choggerell, a limited liability...
-
Lydia Ltd is a small company that operates in the construction industry. The company uses the revaluation model to recognise and measure its property, plant and equipment (PPE). At 1st of January...
-
How do you define social media? Social media marketing?
-
Do enumerated constants have to be unique with a group?
-
Which are more influentialreviews from experts or reviews from customers? Explain.
-
How does the Social Media Value Chain explain the relationships among the Internet, social media channels, social software, and the Internet-enabled devices we use for access and participation?
-
Are all operations available for all data types? Why or why not?
-
Consider a firm with an expected growth rate in dividend payments of 15% per year for the next 6 years based on the analyst consensus forecasts that you have collected. The expected growth rate in...
-
Using the information presented in Problem 13.4B, prepare a partial statement of cash flows for the current year, showing the computation of net cash flows from operating activities using the...
-
Add the following accessor method to the Point class: public int quadrant() Returns which quadrant of the x/y plane the current Point object falls in. Quadrant 1 contains all points whose x and y...
-
Write a program called Egg that displays the following output:
-
Write a Java program called SlashFigure that produces the following output. Use nested for loops to capture the structure of the figure. !!!!!!!!!!!!!!!!!!!!!! 1\!!!!!!!!!!!!!!!!!!//...
-
The percentage of heights between 159 centimeters and 165 centimeters
-
The population of unemployed adults has ages with mean m and standard deviations. Samples of unemployed adults are randomly selected so that there are exactly 100 in each sample. For each sample, the...
-
The percentage of heights less than 144 centimeters
Study smarter with the SolutionInn App