Question
HI can you guys help me with these questions this is c++ btw I'm a little bit confused here cause I'm just starting out c++
HI can you guys help me with these questions this is c++ btw I'm a little bit confused here cause I'm just starting out c++ so yeah. and yes I'm going to give you a thumbs up thank you! ^^
Part A - You are sending a shipment between 2 countries (e.g. China to USA). The program asks the user for information on a shipment.
First: Ask the user if the shipment is "1. Perishable or 2. Non-perishable".
Second: Then ask the user for the weight of the shipment in lbs.
Validate if the input makes sense (e.g. no negative weight).
Then the program proposes shipment by air if it is perishable and weight <1000lb.
Then the program proposes shipment by boat if it is not perishable and weight <2000lb.
Else output that it cannot be shipped.
Part B - Use a switch ... case statement for this exercise. Ask the user to make a menu choice:
1. Bananas
2. Grapefruits
3. Bread
4. Milk
5. Coffee
6. Cookies
Then the program proposes to the user a store with the most affordable prices in your area.
For example, bananas from "Sprouts" or cookies from "Safeway".
This could be useful for a price comparison website. Use the "default" case in your switch statement as well.
Part C
Improve Part A using a while loop.
Continue repeating the loop (asking the user for input and output) until the user inputs the sentinel value -1 to the perishable vs. non-perishable question.
Part D
Improve Part B using a do...while loop.
Continue repeating the loop (asking the user for input and output) until the user inputs the sentinel value -1 to the question.
Part E - practice for loops
Ask the user to enter a positive number n that is greater than 1. Then output all prime numbers up to and including n. If the user enters a value n<=1 exit with an appropriate message.
A prime number is an integer i>1 that can only be divided by 1 and itself with remainder 0. Note: if i<=1 it is NOT prime. For example, the first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.
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