***IN C#*** CIS162AD Programming Assignment 6 Assignment Goal: In this chapter y
ID: 3588241 • Letter: #
Question
***IN C#*** CIS162AD Programming Assignment 6 Assignment Goal: In this chapter you learned about loops. Loops allow processing on large sets of data. They are paramount for processing files. Assignment Specifications: 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 greater than or equal to $500, the customer gets a 5% discount. Calculate a sales tax of 8.25% on the subtotal less the discount. 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 equal to or greater than $500 to test your discount. Deliverables (what you are to submit): A planning document Program outline Data items Sample output Testing criteria Your complete project folder in zip format CIS162AD Programming Assignment 6 Name: _____________________________________ Program Outline: < This is an outline of what your program is to do. Be detailed. > This program will calculate the invoice total for customers after they enter their items, and get their discounts( if applicable). Methods: < This is a list of methods you will define in your program. > Function Access Modifier(1) Method Name Parameters (dataType identifier) Return Type (2) Main method: public static main() void Note: Main() is the only method in this program. 1. Access Modifier: local, public, private, protected 2. Return Type: void, string, char, byte, short, integer, long, double, float, boolean, object, etc. Data Items: < This is a list of fields (variables, constants, and objects you will need. > Data Item Source (1) Access Modifier (2) Data Type (3) Identifier Notes subtotal calculated local float subTotal discount calculated local float discount tax calculated local float tax tax total calculated local float taxTotal customer name input local string customerName customer number input local float customerNumber item description input local string itemDescription item price input local string itemPrice item quantity input local float itemQuantity item name input local string itemName extended amount calculated local float extAmount invoice total calculated local float invoiceTotal 1. Source (where the data comes from): calculated, input, constant, parameter, instance, object 2. Access Modifier: local, public, private, protected 3. Data Type: string, char, byte, short, integer, long, double, float, boolean, object, etc. Sample Output: < What will the user see? > Enter customer number: 99 Enter Customer name: XXXXX Enter item name: XXXXX Enter item description: XXXXX Enter item quantity: XXXXX Enter item price: XXXXX Another item? Y or N: X Customer Number and Name: 99 XXXXX Subtotal: 99999 Discount: 99999 Sales tax: 99999 Total Amount: 99999 Test Data: < How will you prove your program works? > You should list all input and calculated variables under the "Identifier" column. You make up data for the input variables and then manually calculate the calculated variables. You should have at least two customers. Each customer should have at least two items. One of the customers should have an invoice subtotal equal to or greater than $500 to test your discount. Identifier Case 1 Case 2 Case 3 Case 4 Note: You made more or fewer test cases depending on your application.
Explanation / Answer
/* InvoiceGeneration.CPP */
_____________________
Program:
________
#include<iostream>
using namespace std;
struct item
{
string iName;
string description;
int quantity;
double price;
double extendedAmount;
};
class Customer
{
public:
int number;
string name;
item item_arr[10];
double subTotal=0;
double discount;
double salesTax;
double totalAmount;
public:
void dispalyNumName()
{
cout<<number<<" "<<name<<endl;
}
void calculateTotalAmount()
{
if(subTotal>=500)
{
discount = (subTotal * 5)/100;
}
else
{
discount = 0;
}
subTotal -= discount;
salesTax = (subTotal * 8.25)/100;
totalAmount = subTotal + salesTax;
}
};
int main()
{
Customer cust[2];
int i,j;
for(i=0;i<2;i++)
{
cout<<" Enter customer number:";
cin>>cust[i].number;
cout<<"Enter customer name:";
cin>>cust[i].name;
j = 0;
char ch;
do
{
cout<<"Enter item name:";
cin>>cust[i].item_arr[j].iName;
cout<<"Enter item description:";
cin>>cust[i].item_arr[j].description;
cout<<"Enter item quantity:";
cin>>cust[i].item_arr[j].quantity;
cout<<"Enter item price:";
cin>>cust[i].item_arr[j].price;
cust[i].item_arr[j].extendedAmount = cust[i].item_arr[j].price * cust[i].item_arr[j].quantity;
cust[i].subTotal += cust[i].item_arr[j].extendedAmount;
j++;
cout<<" Another item? Y or N:";
cin>>ch;
}while(ch=='Y'|| ch =='y');
}
for(i=0;i<2;i++)
{
cout<<" Invoice of Customer:";
cout<<" ______________________";
cout<<" Customer Number and Name: ";
cust[i].dispalyNumName();
cust[i].calculateTotalAmount();
cout<<"Sub Total: $"<<cust[i].subTotal<<endl;
cout<<"Discount: $"<<cust[i].discount<<endl;
cout<<"Sales Tax: $"<<cust[i].salesTax<<endl;
cout<<"Total Amount: $"<<cust[i].totalAmount<<endl;
}
return 0;
}
Output:
_______
Enter customer number:101
Enter customer name:Lakshman
Enter item name:Soap
Enter item description:SantoorSoap
Enter item quantity:2
Enter item price:25
Another item? Y or N:Y
Enter item name:Paste
Enter item description:ColgatePaste
Enter item quantity:1
Enter item price:82
Another item? Y or N:n
Enter customer number:102
Enter customer name:ManiKumar
Enter item name:Shampoo
Enter item description:HeadandShouldersShampoo
Enter item quantity:1
Enter item price:245
Another item? Y or N:y
Enter item name:Powder
Enter item description:PondsPowder
Enter item quantity:2
Enter item price:176
Another item? Y or N:n
Invoice of Customer:
______________________
Customer Number and Name: 101 Lakshman
Sub Total: $132
Discount: $0
Sales Tax: $10.89
Total Amount: $142.89
Invoice of Customer:
______________________
Customer Number and Name: 102 ManiKumar
Sub Total: $567.15
Discount: $29.85
Sales Tax: $46.7899
Total Amount: $613.94
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.