Your final program must be original and not based on any assignments in this or
ID: 3712698 • Letter: Y
Question
Your final program must be original and not based on any assignments in this or any other course. This project is also assessing your ability to problem solve: Can you design a program from the topics below?
Suggested Topics:
· Statistics (sports, video games, etc...)
· Business (accounting, warehousing, retail, etc...)
· Home inventory system (inventory your belongings, your film collection, your music collection, your antiques collection, etc...)
· Dictionary (Spanish-English, Thesaurus, Quotes, rhymes, Scrabble, etc…)
· Personal finance (Expense tracker, check book, Monthly budget)
· Personal development (calorie tracker, exercise log, to do list, etc…)
Grading Rubric for This Assignment:
?Criteria
Range – Low End (Did not do or did very little effort)
Range – High End (Used correctly and spent time/effort on programming)
Program documentation page Includes the name and description of the project, list of inputs/outputs, and flowchart and instructions on how to use the program. A Word document should be submitted
0
10
Names of variables are meaningful and the program comments self-document the program.
0
10
Math operations (for max points use built-in math functions) NOTE: Increment does not count as a math operation.
0
10
Provide screen shots of the program executed with 3 sets of test data.
0
10
If / else or a switch statement (to get max points use nested if /elses)
0
10
Loops – 2 types (for max points use nested loops)
0
20
Validated user input
0
5
Save the data to a sequential data file and read from it
0
20
At least 3 functions appropriately passing parameters and returning values as needed (to get max points, overloaded function)
0
15
Two dimensional arrays or vectors
0
15
Formatted the output so it is easy to read and aligned
0
10
The program executes without error and the output is correct
0
10
Program, Word document with documentation, screen shots of the code and console are uploaded to dropbox.
0
5
?Total Points Possible
0
?150
Using C++ and prefereably the sports or video game topic, like factoring a hockey goal average or something similar
?Criteria
Range – Low End (Did not do or did very little effort)
Range – High End (Used correctly and spent time/effort on programming)
Program documentation page Includes the name and description of the project, list of inputs/outputs, and flowchart and instructions on how to use the program. A Word document should be submitted
0
10
Names of variables are meaningful and the program comments self-document the program.
0
10
Math operations (for max points use built-in math functions) NOTE: Increment does not count as a math operation.
0
10
Provide screen shots of the program executed with 3 sets of test data.
0
10
If / else or a switch statement (to get max points use nested if /elses)
0
10
Loops – 2 types (for max points use nested loops)
0
20
Validated user input
0
5
Save the data to a sequential data file and read from it
0
20
At least 3 functions appropriately passing parameters and returning values as needed (to get max points, overloaded function)
0
15
Two dimensional arrays or vectors
0
15
Formatted the output so it is easy to read and aligned
0
10
The program executes without error and the output is correct
0
10
Program, Word document with documentation, screen shots of the code and console are uploaded to dropbox.
0
5
?Total Points Possible
0
?150
Explanation / Answer
#include<iostream.h>
#include<conio.h>
class item
{
private:
char name[20];
int code[20];
float price[20];
int z;
public:
void add_(void);
void delete_(void);
void sell_(void);
void display_(void);
void initial(void){z=0;}
};
void item :: add_(void)
{
clrscr();
cout<<" Enter the item category : ";
cin>>name[z];
cout<<"Enter the item code : ";
cin>>code[z];
cout<<"Enter the price of the item: ";
cin>>price[z];
z++;
}
void item :: delete_(void)
{
int i,j;
clrscr();
cout<<" Please enter the item code:";
cin>>i;
for(j=0;j<z;j++)
{
if(code[j]==i)
{
price[j]=0;
cout<<" The item is deleted from the list.";
getch();
break;
}
}
}
void item :: sell_(void)
{
char a;
int i,j;
float total_price=0;
clrscr();
cout<<" Enter the item code:";
cin>>i;
for(j=0;j<z;j++)
{
if (code[j]==i)
{
if(price[j]==0)
{
cout<<" Sorry.There is no item left in this catefory.";
cout<<" Do you want to buy another item? y "<<endl;
cin>>a;
if (a=='y')
{
cout<<" Enter the item code:";
cin>>i;
j=-1;
}
else if (a=='Y')
{
cout<<" Enter the item code:";
cin>>i;
j=-1;
}
else
{
if (total_price!=0)
{
cout<<" Your total price is: ";
cout<<total_price<<" Taka."<<" Thank You.";
}
cout<<"Bye...bye...";
break;
}
}
else
{
cout<<"Item category is: "<<name[j];
cout<<" Item price is : "<<price[j]<<"tk."<<endl;
total_price+=price[j];
price[j]=0;
cout<<" Do you want to buy another item:y ";
cin>>a;
if (a=='y')
{
cout<<" Enter the item code:";
cin>>i;
j=-1;
}
else if (a=='Y')
{
cout<<" Enter the item code:";
cin>>i;
j=-1;
}
else
{ clrscr();
cout<<" Your total price is: ";
cout<<total_price<<"Taka."<<" Thank You.";
break;
}
}
}
}
getch();
}
void item :: display_()
{
int i,j=1;
clrscr();
for(i=0;i<z;i++)
{
cout<<j<<".Item category is: "<<name[i];
cout<<" Item code is : "<<code[i];
cout<<" Item price is : "<<price[i]<<"tk."<<endl<<endl;
j++;
}
getch();
}
int main ()
{
int i;
item shoping_mall;
clrscr();
shoping_mall.initial();
while(1)
{
cout<<" What do you want to do?"<<endl;
cout<<" 1: Add a new item.";
cout<<" 2: Delete an item.";
cout<<" 3: Sale an item.";
cout<<" 4: Display all items.";
cout<<" 5: Exit"<<endl;
cout<<" Choose a number:";
cin>>i;
switch(i)
{
case 1:
{
shoping_mall.add_();
break;
}
case 2:
{
shoping_mall.delete_();
break;
}
case 3:
{
shoping_mall.sell_();
break;
}
case 4:
{
shoping_mall.display_();
break;
}
case 5:
{
cout<<"Good Bye! Thank you.";
break;
}
}
if (i==5)
break;
clrscr();
}
getch();
return 0;
}
PS: Run this code in TC and you are good to go.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.