Concept explainers
Write a
Examples of numbers that would result in an output of YES: 101, 50, 75, 55, 70, 71, 250
Examples of numbers that would result in an output of NO: 49, 76, 100, 80, 10, −50, 0
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (7th Edition)
Concepts of Programming Languages (11th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with C++: Early Objects
Web Development and Design Foundations with HTML5 (8th Edition)
Absolute Java (6th Edition)
- Write a program that specifies whether a given number (x) falls in one of the following categories (give x a value from the code, don't read from user): • 0 to 9 • 10 to 19 • 20 to 29 • None of the categories. For example: if x = 5, program should print "0 to 10", and if x = 44 it should print "None". Hint: use if statements with Boolean expressions combined using && .Use C++ programarrow_forwardWrite aC++program that allows a user to enter their rating of the three movies in the DarkKnight Trilogy: Batman Begins/ The Dark Knight /The Dark Knight Rises Ratings must be between 1 and 5. If a rating entered is less than 1 or more than 5, display anappropriate message and do not use the rating. After all the ratings have been entered, display each rating entered, the highest rating, the lowest rating, and the average of the ratings.arrow_forward1. Use if - else - elif Write a program to get an integer input from the user. If the input is 25, get the length and breadth from the user and calculate the area of rectangle. [ Area of rectangle = length * breadth ] If the input is 40, get the side from the user and calculate the area of square. [ Area of square = side * side] If the input is 65, get the radius from the user and calculate the area of circle. [ Area of circle = 3.14"r*r] Otherwise Display Enter number 25 or 40 or 65. 2. Use while loop to print the even numbers from 100 to 50. Print the product of all the even numbers.arrow_forward
- Write a program that specifies whether a given number (x) falls in one of the following categories(give x a value from the code, don't read from user):• 0 to 9• 10 to 19• 20 to 29• None of the categories.For example: if x = 5, program should print "0 to 10", and if x = 44 it should print "None". Hint:use if statements with Boolean expressions combined using &&.arrow_forward*2. Express the following Boolean expressions in simpler form; that is, use fewer operators. x is an in (d) !(x <= y)arrow_forwardThe first 11 prime integers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31. A positive integer between 1 and 1000 (inclusive), other than the first 11 prime integers, is prime if it is not divisible by 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31. Write a program that: Prompts the user to enter a positive integer between 1 and 1000 (inclusive) Outputs whether the number is prime. If the number is not prime, then output all the numbers, from the list of the first 11 prime integers, which divide the number. In C also the output should look like this Enter an integer between 1 and 1000 (inclusive): 6262 is divisible by 2, 31.62 is not prime. ---------------------------------------------------- Enter an integer between 1 and 1000 (inclusive): -1You must enter a number between 1 and 1000 (inclusive). ---------------------------------------------------- Enter an integer between 1 and 1000 (inclusive): 33 is prime.arrow_forward
- Write an if-else statement for the following: If barcode_check_digit is not equal to 7, execute group_id = 10. Else, execute group_id = barcode_check_digit. Ex: If barcode_check_digit is 14, then group_id = 10. 1 þarcode_check_digit 23 456 ... int(input()) # Program will be tested with values: 6, 7, 8, 9. Your code goes here '' 5 print(group_id)arrow_forwardWrite a program that given an amount of change less than $1.00 will print out exactly how many quarters, dimes, nickels, and pennies will be needed to efficiently make that change. [Hint: the // operator may be useful.]arrow_forward1. Write a program that prompts the user to enter an integer between 0 and 6 and prints thie day name of the week (Sunday is 0, Monday is 1,..., and Saturday is 6). 2. Write a program that prompts the user to enter an integer and tests if it is divisible by 5 and 3, or if its divisible by 5 or 3 or if its divisible by 5 or 3 but not both.arrow_forward
- Write a program that inputs an integer. If the integer is greater than 100 or between 50 and 75 (inclusive) then output YES. Otherwise, output NO. Your program should use an if-else statement along with && (and) and || (or) relational operators. Examples of numbers that would result in an output of YES: 101, 50, 75, 55, 70, 71, 250 Examples of numbers that would result in an output of NO: 49, 76, 100, 80, 10, −50, 0arrow_forwardWrite an expression that obtains a random integer between 34 and 55. Write an expression that obtains a random integer between 0 and 999.arrow_forwardWrite a program that reads the following information and prints a payroll statement: Employee’s name (e.g., Smith) Number of hours worked in a week (e.g., 10) Hourly pay rate (e.g., 9.75) Federal tax withholding rate (e.g., 20%) State tax withholding rate (e.g., 9%) A sample run is shown below: Enter employee's name: Smith Enter number of hours worked in a week: 10 Enter hourly pay rate: 9.75 Enter federal tax withholding rate: 0.20 Enter state tax withholding rate: 0.09 Employee Name: Smith Hours Worked: 10.0 Pay Rate: $9.75 Gross Pay: $97.5 Deductions: Federal Withholding (20.0%): $19.5 State Withholding (9.0%): $8.77 Total Deduction: $28.27 Net Pay: $69.22arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,