Chapter 5, Exercise #6 with Visual Logic.The Jumpin’ Jive …

Chapter 5, Exercise #6  with Visual Logic. The Jumpin’ Jive coffee shop charges $2.00 for a cup of coffee and offers the add-ins shown in Table 5-3. Product                                              Price ($) Whipped cream                                0.89 Cinnamon                                         0.25 Chocolate sauce                              0.59 Amaretto                                         1.50 Irish whiskey                                   1.75 Table 5-3

Answer

Jumpin’ Jive coffee shop price list for add-ins.

The task at hand is to create a program with Visual Logic that calculates the total cost of a cup of coffee with add-ins based on the prices provided in Table 5-3. The program should prompt the user to select which add-ins they would like and display the total cost.

To complete this exercise, we will need to use decision structures and variables in Visual Logic. We will also incorporate user input and output statements to interact with the program.

Let’s start by setting up the program structure. We will create a module for our main program, which we can call “JumpinJiveCoffeeShop.” Within this module, we will declare variables for the prices of each add-in and the total cost of the coffee.

We can set the prices of each add-in as constants within the module, as these values are not expected to change. For example, we can declare the price of whipped cream as 0.89 using the statement “Constant whippedCreamPrice = 0.89.”

Next, we will prompt the user to select their desired add-ins. We can accomplish this by using an input statement and assigning the selected add-ins to variables. For example, we can prompt the user to enter a 1 if they want whipped cream and a 0 otherwise. We will assign the user’s response to a variable, such as “whippedCreamSelected.”

After gathering the user’s input, we will calculate the total cost of the coffee. To do this, we will use decision structures to determine which add-ins were selected and add the corresponding prices to the total cost variable.

For example, if the user selected whipped cream, we can use an “If…Then” statement to check if “whippedCreamSelected” equals 1. If it does, we will add the price of whipped cream to the total cost of the coffee.

We can repeat this process for each add-in, checking if the variable representing that particular add-in is equal to 1 and adding its price to the total cost if it is selected.

Finally, we will display the total cost to the user using an output statement. For example, we can use the statement “Output ‘The total cost of your coffee is $’ + totalCost” to inform the user of the final price.

In conclusion, this exercise requires the use of Visual Logic to create a program that calculates the total cost of a cup of coffee with add-ins based on the prices provided in Table 5-3. By utilizing decision structures, variables, user input, and output statements, we can prompt the user to select their desired add-ins, calculate the total cost of the coffee, and display the price to the user.

Do you need us to help you on this or any other assignment?


Make an Order Now