Starting from:
$30

$27

Program #1 fundamental syntax of C++

CS162  Program #1
Programming Assignment #1
CS 162: Introduction to Computer Science
Submit your assignment to the D2L’s Assignments (in Activity tab)
The purpose of this first program is get you familiar with the fundamental syntax of
C++ and the process of writing and turning in programs at PSU. Think of this program
as a way to demonstrate some simple interactions between the user and program. For
those of you who already know C++, use this program as a refresher and stretch
yourself to do more than is assigned!
To get full credit for the programming portion, you will need to:
1. Turn in an algorithm written using full English sentences (the algorithm
will be pass/no-pass for the first assignment). It should be supplied as part
of your header comments. The algorithm needs to be at least 400 words.
2. Program using a consistent style of indentation, header comments for each
function, inline comments for each major block of code. This is also worth
20% of the assignment’s grade.
3. Submit an electronic copy of your .cpp file as an attached file to D2L.
Program Assignment:
Background: How are you doing buy groceries? Are you going into the store, getting
delivery from Prime Now or Instacart, or are you reserving a time slot for pick-up? It is
amazing how quickly we are rethinking how we take care of what used to be normal every
day activities. I’ve tried purchasing on line and then picking it up at a designated time. As
I add items into my “cart” it adds a total into the virtual shopping cart so I know how
much I am spending. This part is important so I know when to stop shopping because I am
out of money. In a way I wish a in-store shopping cart would give me a running total of my
purchases. Wouldn’t that be great?
Your job will be to write a C++ program to compute the running total of all of the
purposes made as we shop for items. Give the user a list of possible items to
purchase and then the user specifies the price and quantity. In this assignment you
are allowed to use “strings” if you want the user to be able to type in the name of
their purchases, but this part is not required. This is a program to create a total
amount being spent – it is NOT keeping track of the actual items in the shopping
cart.
The running total should start at zero and each an item is selected by the user, the
total is increased and displayed to the user. After each item is selected, the user
should be asked if they really want to add it t their cart or if it should be removed.
CS162 Spring 2020 Program #1
Then, they should be asked if there is another item that the user would like to
purchase. This should continue until the user wants to quit. The grand total should
be displayed after this.
To get dollars and cents to display nicely, review the power point slides for Topic
#1 on output formatting. You will want to put these lines at the beginning of main:
cout.setf(ios::fixed, ios::floatfield); // we want a fixed point presentation
cout.precision (2); // we want two digits after the decimal point
cout.setf(ios::showpoint); //if the values are zero, we still want to see them
Things you should know...as part of your program:
1. Make sure to use a loop.
2. Make sure to prompt the user for any input requested. Make sure it is clear
from your prompts what the user is expected to do.
3. You may not use any global variables in this program!
4. Make sure to use C++’s I/O (iostream library) for I/O
5. And, don’t forget to add comments and to work on your program’s readability; this is
another 20%!!

More products