Concept explainers
Find the errors in the following code:
3. // Warning! This code contains ERRORS!
if (num2 == 0)
System.out.println(“Division by zero is not possible.”);
System.out.println(“Please run the
System.out.println(“and enter a number besides zero.”);
else
Quotient = num1 / num2;
System.out.print(“The quotient of ” + Num1);
System.out.print(“ divided by ” + Num2 + “ is ”);
System.out.println(Quotient);
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
C Programming Language
Starting Out with Python (4th Edition)
Concepts of Programming Languages (11th Edition)
Problem Solving with C++ (9th Edition)
Artificial Intelligence: A Modern Approach
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- Problem definition: A college wants to know how well its students did on an exam. The following program summarizes the results. The program asks a user to enter the results pass (1) or fail (2) for 10 students. It displays the number of passed and the number of failed. It displays a message "Raise error" if the number of passes is more than 8 You are asked to identify statement with syntax errors by selecting them as wrong and the correct statements as rightarrow_forwardTime CalculatorWrite a program that asks the user to enter a number of seconds.-There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes and leftover seconds in that many seconds.-There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours, minutes, and leftover seconds in that many seconds.-There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days, hours, minutes, and leftover seconds in that many seconds.arrow_forward1. Write a program that lets the user guess whether a randomly generated integer would be even or odd. The program randomly generates an integer and divides it by 2. The integer is even if the remainder is 0, otherwise odd. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect.arrow_forward
- 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. C codearrow_forwardالسبت ۲ أكتوبر المحاولة رقم 1 :2 HW • Write a program that computes the average of 5 students grades which are entered by the user. Write a program that converts pounds into kilograms. The program prompts the user to enter a number in pounds, converts it to kilograms, and displays the result. One pound is 0.454 kilograms. محتوى إضافي؟ يمكنك إضافة نص وملفات تدعم إجاباتك. إضافة محتوی إرسال الحفظ لوقت لاحقarrow_forward3- Enter a=3; b-5; c=7, then clear the variable b only Matlabarrow_forward
- Write assignment statements that perform the following operations with the variables a and b (Python)A. Adds 2 to a and stores the result in bB. Multiplies b times 4 and stores the result in aC. Divides a by 3.14 and stores the result in bD. Subtracts 8 from b and stores the result in aarrow_forwardBox Office: A movie theater only keeps a percentage (20%) of the revenue earned from ticket sales. The remainder goes to the movie distributor. Write a program that calculates a theater’s gross and net box office profit for a night. The program should ask for the name of the movie, and how many adult and child tickets were sold. (The price of an adult ticket is $10.00 and a child’s ticket is $6.00.) Input: the name of the movie, number of adult tickets sold, number of child tickets sold Output: as specified below Object: cin, cout, getline, format output Note: 1. Movie names contain spaces 2, the report is aligned. 3. The decimal number is displayed with 2 decimal places.arrow_forward3.Professor Mysterious uses a special formula to calculate the grade of his students. Write a program that repeatedly does the following: a. Prompt the user to enter the grade of the first test b. Prompt the user to enter the grade of the second test . Prompt the user to enter the grade of the third test. The program should then calculate and displays the student grade based on the following formula: grade-.25*testi+.61 test2+.14 test3 NOTE: Exit the program using sentinel or magic value. SAMPLE PROGRAM RUN Enter Test1 (0 to exit): 100 Enter Test2:90 Enter Test3:87 Grade: 92.08 Enter Test1 (0 to exit): 0 Thank you for using this program.arrow_forward
- Question: Write program that asks the user to enter car information for 3 cars. The user will read the car plate number, driven mileage and number of months since last service. The program should display the message ‘Car is due for service’ if one of the following is true: The car drove more than 5000 KM The program should also count and display the number of cars due for service. Input/Output example: Enter car plate number: 600600 Enter the mileage and number of months since last service: 5230 Car is due for service Enter car plate number: 600666 Enter the mileage and number of months since last service: 5002 Car is due for service Enter car plate number: 600222 Enter the mileage and number of months since last service: 1500 The number of cars due is: 2arrow_forwardWrite MARIE assembly language code to implement the following algorithm:arrow_forwardWhen parentheses are nested, which set of parentheses is evaluated first in an arithmeticexpression?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning