5
Programming Fundamentals Assignment 4 Planning Document You will have 5 parts to your planning document that must be completed: Actions Data Items Prototype/Mock/Sample Output Test Data Process Design (Pseudocode/Flowchart) Assignment Goal: In this chapter you learned about loops. Loops allow processing on large sets of data. Problem Statement: Write a program called CalculateInvoice that allows a user to enter multiple invoice items for multiple customers and calculates a total invoice amount. For each customer, enter a customer number and customer name. Then, for each customer allow the user to enter any number of items. Data to be entered for each item is the description, quantity, and price. For each item calculate the extended amount by multiplying the quantity times the price. Add each extended amount to a subtotal for the customer. If the subtotal is over $500, the customer gets a 5% discount. After the discount has been calculated, calculate a sales tax of 8.25%. Display the customer number and name on the first line, followed by the subtotal, the amount of discount, amount of sales tax, and total invoice amount. You are not to list the individual items. Hint: You will need two loops for this assignment, an outer loop for multiple customers and an inner loop for multiple items. Because you have multiple customers, you need to clear (set to zero) all fields used to store customer level totals) in order to prevent values from carrying over to the next customer. For your test data, you should have at least two customers. Each customer should have at least two items. One of the customers should have an invoice subtotal over $500 to test your discount. Deliverables (what you are to submit): Planning Document List of actions your program is to do. List of data items. A prototype/mock screen showing the output of your program. A set of test data with expected results. Your solution algorithm using pseudocode and a flowchart.

fornick.docx

Embed Size (px)

Citation preview

Page 1: fornick.docx

Programming Fundamentals Assignment 4Planning Document

You will have 5 parts to your planning document that must be completed:• Actions• Data Items• Prototype/Mock/Sample Output• Test Data• Process Design (Pseudocode/Flowchart)

Assignment Goal:

In this chapter you learned about loops. Loops allow processing on large sets of data.

Problem Statement:

Write a program called CalculateInvoice that allows a user to enter multiple invoice items for multiple customers and calculates a total invoice amount. For each customer, enter a customer number and customer name. Then, for each customer allow the user to enter any number of items. Data to be entered for each item is the description, quantity, and price. For each item calculate the extended amount by multiplying the quantity times the price. Add each extended amount to a subtotal for the customer. If the subtotal is over $500, the customer gets a 5% discount. After the discount has been calculated, calculate a sales tax of 8.25%. Display the customer number and name on the first line, followed by the subtotal, the amount of discount, amount of sales tax, and total invoice amount. You are not to list the individual items.

Hint: You will need two loops for this assignment, an outer loop for multiple customers and an inner loop for multiple items. Because you have multiple customers, you need to clear (set to zero) all fields used to store customer level totals) in order to prevent values from carrying over to the next customer.

For your test data, you should have at least two customers. Each customer should have at least two items. One of the customers should have an invoice subtotal over $500 to test your discount.

Deliverables (what you are to submit):

• Planning Document• List of actions your program is to do.• List of data items.• A prototype/mock screen showing the output of your program. • A set of test data with expected results.• Your solution algorithm using pseudocode and a flowchart.

Name: ____Aaron Villalobos____________________________________ Assignment: Chapter 4 Program

Actions (2 points):

Start Program

Page 2: fornick.docx

Ask for amount of customersSet that number as outer loop{Ask for customer number Store customer numberAsk for customer nameStore customer name Ask how many items to be enteredStore amount as inner loop number

{ Enter description of item. Enter quantity of item. Enter price of item. Price * quantity = itemsum subtotal += itemsum}

Loop for item number entered before.if subtotal > 500 then subtotal * .05 = discount subtotal - discount = totaltotal * 0.825 = taxtotal + tax = taxtotal

Print customer number and name, endl.print subtotal, discount, tax, taxtotal

Set all variables to 0.Add 1 to customer amount loop} loop based on how many customers input at the beginning.End if loop = customers

Data Items (3 points): < This is a list of fields (variables, constants, and objects you will need >

Data Item Source (1) Type (2) Identifier Notessubtotal calculated double subTotaldiscount calculated double discount

total calculated double total

tax calculated double tax

taxTotal calculated double taxTotal

loopCustomers input double loopCustomers

loopItems input double loopItems

customerName input string customerName

customerID input double customerID

itemDescription input string itemDescription

itemNumber input double itemNumber

itemPrice input double itemPrice

1. Source: calculated, input, constant

Page 3: fornick.docx

2. Type: string, char, byte, short, integer, long, double, float, etc.

Sample Output (5 Points):

Please enter amount of customers to be processed : 1Please enter your customer ID: 1234Please enter customer name: John SmithPlease enter the amount of items to be processed: 2Enter description of item (loop number): ChipsEnter quantity of item (loop number): 3Enter price of item(loop number): $ 2 // The dollar sign is part of the program output, not the input //(This loops depending on amount of items and customers)

Customer 1234 John Smith Subtotal: 6.00 Discount: 0 Tax: .49 Total: 6.49

Test Data (5 points): < How will you prove your program works >

Identifier Value 1 Value 2 Value 3 Value 4itemPrice 5.00 40.00 1.50 15.00itemNumber 10 2 20 17subtotal 50.00 80.00 30.00 255.00tax 4.13 6.60 2.48 21.04taxTotal 54.13 86.60 32.48 276.04

Note: You made more or fewer test cases depending on your application.

Process Design (10 points): < What is the solution (pseudocode, IPO diagram, flowchart) >

NOTE: Please see the syntax summary document for guidelines.

You will define your process using both psuedocode and a flowchart.

class CalculateInvoicevoid main()double subtotal;double discount;double total;

double tax; double taxTotal;

double loopCustomers;double customerCheck;double loopItems;

string customerName;double customerID;string itemDescription;double itemNumber;double itemPrice;double itemSum;

Page 4: fornick.docx

double itemCheck = 0;

display “Please enter amount of customers to be processed :” read loopCustomers

dodisplay “Please enter your customer ID:” read customerIDdisplay “Please enter customer name:” read customerNamedisplay “Please enter the amount of items to be processed:”read loopItems

dodisplay “Enter description of item (loop number):”read itemDescriptiondisplay “Enter quantity of item (loop number):”read itemNumberdisplay “Enter price of item(loop number): $”read itemPrice

itemPrice * itemNumber = itemSumsubtotal += itemSumitemCheck += 1itemPrice = 0itemNumber = 0itemSum = 0

while itemCheck < loopItems

if subtotal > 500 {discount = subtotal * .05 }

else discount = 0

total = subtotal - discounttax = total * 0.825taxTotal = total + tax

display customer number, display customer name; endl;display subtotal, discount, tax, taxtotal

customerID = 0customerName = nullcustomerCheck += 1while customerCheck < loopCustomers

returnend class

AND

Page 5: fornick.docx

Flowchart: (Graphic representation of a process)