Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Let s say we had a shop, MyShoppe, and wanted to prompt for the shop name. We would use: This will store the user entered
Lets say we had a shop, MyShoppe, and wanted to prompt for the shop name. We would use: This will store the userentered shop name into the variable shopName. Lets prompt for the quantity of items in the shop, a ring and glasses. Run the program as it is; it prompts for user input, but doesnt output anything. Lets add print statements for our current variables Test the program. We can see that the program works and prints the correct quantities that we entered. Lets say we wanted to add up all of our inventory in our shop and print the total. Try: What do you think the inventory total will be if we have rings and glasses? Test it run the program
Notice how the output is and not Why is that? Well, when you take a value from input it is a string value by default. So when we ask for the shop name, it is a string value. When we ask for the QTY it is also a string value by default. What is happening when we add these quantity string values is they are being concatenated. This means we
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started