Concept explainers
Rewrite the following If-Then-Else If statement as a Select Case statement.
If selection == 1 Then
Display "You selected A."
Else If selection == 2 Then
Display "You selected 2."
Else If selection == 3 Then
Display "You selected 3."
Else If selection == 4 Then
Display "You selected 4."
Else
Display "Not good with numbers, eh?"
End If
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Introduction to Programming Using Visual Basic (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Rewrite the following if-else-if statement as a switch statement.if (selection == 1){ MessageBox.Show("You selected 1.");}else if (selection == 2){ MessageBox.Show("You selected 2.");}else if (selection == 3){ MessageBox.Show("You selected 3.");}else if (selection == 4){ MessageBox.Show("You selected 4.");}else{ MessageBox.Show("Not good with numbers, eh?");}arrow_forwardA software company sells a package that retails for $109. Quantity discounts are givenaccording to the following table.Quantity Discount10 - 39 10%40 - 65 18%66 - 90 27%91 - 120 35%121 – 199 42%200 or more 48%Write a program using the if/else if/else statement that asks for the number of units soldand computes the total cost of the purchase and the savings due to the discountapplied. The program should also display the number of units purchased and thediscount in percentage. The output should include the following text:Number of units purchased is:Discount applied is:Total savings due to discount is:The total cost of the purchase is:Do NOT use the switch statement, any logical operator or anything that looks likeone in the program. You will not receive credit for the program if you do. SeeProgram 4-9 on page 183 of your textbook for help.Don’t forget to include the developerInfo function and do not accept negative quantityvalues.arrow_forwardWrite an if statement for the following: use if/else statement that assigns 0.10 to commission unless sales is greater than orequal to 50000, in which case it assigns 0.20 to commission.arrow_forward
- Expression a | b (means: a OR b) is true only when either a or b is true, but not when both a and b are true. Yes Noarrow_forwardA company manufactures three products engines, pumps and fans. They give a discount of 10% on orders for engines if the order is for Rs. 10000 or more. The same discount is applicable for pumps whose value is more than Rs. 5000 and fans whose order value is more than Rs. 3000. Write a program to calculate the total bill for 6 engines of Rs. 12000 each, 4 pumps of Rs. 6000 and 6 fans of price 2500. Hint use if else statement.arrow_forwardWrite out an IF-THEN-ELSE statement for the following conditions: 1. A person has credit card points and if the number of points entered > 4,999 then output “Enough points for Selection” otherwise output “Not Enough points for Selection” using Variable Points Available. 4. A customer is buying a car for $20,000 and wants to upgrade the stereo speakers for an additional $100. However, if the customer gets the extended stereo package for $250 which includes the upgraded speakers, XM radio, and upgraded visual display. Use variables CarPrice, UpgradedSpeakers and ExtendedStereo for the IF statement. Show the calculation for the total cost of the car depending on options selected.arrow_forward
- Write an if-else statement that works like this: If the sales variable is greater- than or equal-to 50,000, the commissionRate variable should be assigned the value 0.2. Otherwise, the commissionRate variable should be assigned the value 0.1.arrow_forwardExpression a & b (means a AND b) is true only when both a and b are true. Yes Noarrow_forwardwrite an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100.arrow_forward
- Write an if statement that assigns 0.2 to commissionRate if sales is greater than or equal to 10000.arrow_forwardWrite an if-else statement that works like this: If the sales variable is greaterthan or equal-to 50,000, the commissionRate variable should be assigned the value 0.2. Otherwise, the commissionRate variable should be assigned the value 0.1.arrow_forwardWrite an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100. Write an if statement that assigns 0 to the variable b, and assigns 1 to the variable c if the variable a is less than 10. Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. Write nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education