$39
Objectives
Introduction: Mission to Mars
Your friend has been playing a new Mars Colony simulator nonstop! They are always talking about how cool it would be if they could be a on the first real-life mission to Mars! To amuse your friend, you have decided to create a series of programs about the possible first colony on Mars.
Problem: Where Can We Get the Best Deal? (marssupplier.c)
Now that we know how much fuel we need and how much equipment we can take, we need to determine which supplier will give us the best deal on what we need to purchase. We will poll a number of suppliers to see what kind of pricing they can give us and select the supplier who has the best deal.
In this program, we want to ask the user for information about suppliers. We can assume that there will be at least one supplier, but we will not know ahead of time how many suppliers there might be. After each supplier’s information, ask the user if there is another supplier to consider.
For each supplier, ask the user for the deal that the supplier is willing to offer. Keep track of the best possible deal and which supplier (identified as a number: 1, 2, 3, etc.) is offering it. After all the suppliers have been considered, tell the user which supplier offered the best deal.
Input Specification
Output Specification
For each supplier, prompt the user with:
What is the price for supplier #X?
To ask about additional suppliers, prompt the user with:
Is there another supplier to consider?
For the final print out, tell the user which supplier they should select, including the best price rounded to two decimal places:
Supplier #X had the best price at $Y.YY.
2
Output Samples
Below are some sample outputs of running the program. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for clarity’s sake.)
Sample Run 1
What is the price for supplier #1?
500.49
Is there another supplier to consider?
N
Supplier #1 had the best price at $500.49.
Sample Run 2
What is the price for supplier #1?
250.39
Is there another supplier to consider?
Y
What is the price for supplier #2?
500.49
Is there another supplier to consider?
Y
What is the price for supplier #3?
178.72
Is there another supplier to consider?
Y
What is the price for supplier #4?
300.00
Is there another supplier to consider?
N
Supplier #3 had the best price at $178.72.
Acceptable Resources
Remember, the use of online help sites is strictly prohibited. The only acceptable resources for these assignments are below:
Course Webcourse
3
Professor Guha’s Course Archive
Style Notes
Please review the course Style Guide on the webcourse, with special attention to the following notes:
comment major sections of code addressing: “What does this block do?” and “Why did I implement this block in this way?”
place comments above the line(s) to which it applies
use inline comments (//) and leave one space between // and the comment’s first character
All variables should be declared at the top of your functions (in this program, only main is needed) and should have meaningful names
Be sure to declare main with: int main(void) {
Indent the contents of main four spaces or one tab
leave a space on both sides of any binary operators you use in your code (i.e., operators that take two operands). For example, use (a + b) - c instead of (a+b)-c.
keywords if and while should have a single space after them
contents of if statements and loops should be indented four spaces or one tab
conditions should not have any space immediately after each ( or immediately before each ) .
Deliverables
One source file – marssupplier.c – is to be submitted over WebCourses.
Restrictions
Although you may use other compilers, your program must compile and run using a standard C Development Environment. Your program should include a header comment with the following information: your name, assignment number or title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem.
Grading Details
Your programs will be graded upon the following criteria: