Concept explainers
What output is produced by the following code? For each output line, describe whether the line begins or ends with a blank or blanks.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Digital Fundamentals (11th Edition)
Starting Out With Visual Basic (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Database Concepts (8th Edition)
- Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9.". End with newline. 1 import java.util.Scanner; 2 public class UserNums { public static void main (String [] args) { int userNum1; int userNum2; 4 6. 7 Scanner input userNum1 = 8. = new Scanner(System.in); input.nextInt(); input.nextInt(); 9. 10 userNum2 11 12 V* Your code goes here */ 13 System.out.println("userNum2 is " } 14 + userNum2); 15 16 17 }arrow_forwardPrint "user_num1 is negative." if user_num1 is less than 0. End with newline. Assign user_num2 with 1 if user_num2 is greater than 12. Otherwise, print "user_num2 is less than or equal to 12.". End with newline. My code: user_num1 = int(input())user_num2 = int(input()) if user_num1 < 0: print("user_num1 is negative.") if user_num2 > 12: user_num2 == 1 else: print("user_num2 is less than or equal to 12.") print('user_num2 is', user_num2) When the input is 0 and 13 my output for user_num2 is 13 and it should be 1. I don't know what I'm doing wrong.arrow_forwardUse the compareTo method to write code that reads two names from the console and prints the one that comes first in alphabetical order. For example, the program's output might look like the following: Type a name: Tyler Durden Type a name: Marla Singer Marla Singer goes before Tyler Durdenarrow_forward
- Write code that outputs variable numMonths as follows. End with a newline. Ex: If the input is: 3 the output is: Months: 3 Phyton codearrow_forwardChoose the correct answer int a = 11, b = 22, c = 33, d=1003; d = d - ((a * a + b - c) + (c - a) * b); if (d < a) Console.WriteLine("The value of D is less than A"); else Console.WriteLine("The value of D is greater than A"); Select one: O The value of Dis less than A O The value of D is greater than A O Program Error O No outputarrow_forwardPrint "Censored" if userlnput contains the word "darn", else print userlnput. End with newline. Ex: If userlnput is "That darn cat.", then output is: Censored Ex: If userlnput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message. 1 import java.util.Scanner; 2 3 public class CensoredWords { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userInput; 4 5 7 8 userInput scnr.nextLine(); 9. 10 /* Your solution goes here */ 11 } 13 } 12arrow_forward
- Write a program that helps a company manage salaries of its employees. Your program should ask for the number of hours worked and the hourly rate of an employee than, display the salary. This program should allow the user to enter the information of many employees until enters -1. Sample Run: Enter the number of hours worked (-1 to end): 32 Enter hourly rate of the worker: 100 Balary is 03200 Enter the number of hours Worked (-1 to end) : 40 Enter hourly rate of the worker: 5 Balary is 3200 Enter the number of hours worked (-1 to end): 42 Enter hourly rate of the worker: 10 Salary is 0420 Enter the number of hours worked (-1 to end) : -1arrow_forwardoptions same for each onearrow_forwardTask 5: ScanningMoney.java Write a program that reads User Input using the Scanner class. Your program should ask the user how many quarters, nickels, dimes, and pennies they have, then display the total amount in dollars. This can be done in main method. Expected Output The highlighted text denotes text that you type into the console yourself. It is not printed by the program. Due to floating point values being used your answer may have the trailing 1 or not. ----JGRASP exec: java ScanningMoney Quarters: 4 Dimes: 3 Nickels: 2 Pennies: 1 You have $1.4100000000000001 ----JGRASP: operation complete.arrow_forward
- What is the output of the following code when x is * .equal 5 x = CInt(Text1.Text) If x = 1 Then MsgBox ("Sunday") Elself x = 2 Then MsgBox ("Monday") Elself x = 3 Then MsgBox ("Tuesday") Elself x = 4 Then MsgBox ("Thursday") Elself x = 5 Then MsgBox ("Wednesday") Elself x = 6 Then MsgBox ("Friday") Elself x = 7 Then MsgBox ("Saturday") Else MsgBox ("This is not correct number") End If All of the above O This is not correct number Sunday Non of the above Wednesday Oarrow_forwardWrite a code that asks the user to enter several numbers that are a multiple of 5. If the user enters a value that is not a multiple of 5 it should print a message and prompt the user to enter a new number. The user can stop the process by inputting the string *done*. At the end, print the total number of values entered that are a multiple of 5.arrow_forwardWhen the given integer variable numberOfTools is: less than 14, output "Small tool box". between 14 inclusive and 39 inclusive, output "Mid-sized tool box". greater than 39, output "Need wall storage". End with a newline. Ex: If the input is 13, then the output is: (in java) Given Code: import java.util.Scanner; public class ToolDetails {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int numberOfTools; numberOfTools = scnr.nextInt();arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT