0% found this document useful (0 votes)
5 views8 pages

Print

The document contains a C++ program that implements a simple inventory management system using a class named LIST. Users can add items, delete items, display the list of items, and show the total amount to be paid. The program runs in a loop until the user chooses to exit, handling various user inputs and displaying appropriate messages.

Uploaded by

advayborkariit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Print

The document contains a C++ program that implements a simple inventory management system using a class named LIST. Users can add items, delete items, display the list of items, and show the total amount to be paid. The program runs in a loop until the user chooses to exit, handling various user inputs and displaying appropriate messages.

Uploaded by

advayborkariit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

COMPUTER ASSIGNMENT

ADVAY GAURISH SINAI BORKAR

XII A 504

PROGRAM
1 #include <iostream>

2 #include <iomanip>

3 using namespace std;

5 class LIST {

6 unsigned short int code;

7 char name[30];

8 int qty;

9 float price;

10 float amount;

11

12 static int count;

13 static float total;

14

15 public:

16 LIST() {

17 code = 0;

18 name[0] = '\0';

19 qty = 0;

20 price = 0.0;

21 amount = 0.0;

22 }
23

24 void getdata() {

25 cout << "Enter item code, name, quantity and price: " << endl;

26 cin >> code >> name >> qty >> price;

27 amount = qty * price;

28 count++;

29 total += amount;

30 }

31

32 void showlist() {

33 cout << setw(10) << code

34 << setw(15) << name

35 << setw(10) << qty

36 << setw(10) << price

37 << setw(10) << amount << endl;

38 }

39

40 unsigned short int getcode() {

41 return code;

42 }

43

44 void del_item() {

45 total -= amount;

46 qty = 0;

47 price = 0;

48 amount = 0;

49 }
50

51 static void showtotal() {

52 cout << "Final Amount to be paid is Rs. " << total << endl;

53 }

54 };

55

56 int LIST::count = 0;

57 float LIST::total = 0.0;

58

59 int main() {

60 LIST obj[50];

61 int choice;

62 int n = 0;

63

64 do {

65 cout << "\nYou can do the following:\n";

66 cout << "1. Add an item\n";

67 cout << "2. Delete an item\n";

68 cout << "3. Display list\n";

69 cout << "4. Display total\n";

70 cout << "5. Exit\n";

71 cout << "Enter your choice:\n ";

72 cin >> choice;

73

74 switch(choice) {

75 case 1:

76 obj[n].getdata();
77 n++;

78 break;

79

80 case 2: {

81 unsigned short int c;

82 cout << "Enter item code of the item to be deleted: ";

83 cin >> c;

84 for (int i = 0; i < n; i++) {

85 if (obj[i].getcode() == c) {

86 obj[i].del_item();

87 break;

88 }

89 }

90 break;

91 }

92

93 case 3:

94 cout << "\n" << setw(10) << "Item Code"

95 << setw(15) << "Item Name"

96 << setw(10) << "Quantity"

97 << setw(10) << "Price"

98 << setw(10) << "Amount" << endl;

99 for (int i = 0; i < n; i++) {

100 obj[i].showlist();

101 }

102 break;

103
104 case 4:

105 LIST::showtotal();

106 break;

107

108 case 5:

109 cout << "Thank you and visit again." << endl;

110 break;

111

112 default:

113 cout << "Invalid choice! Please try again." << endl;

114 }

115 } while(choice != 5);

116

117 return 0;

118 }

Output
You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display total

5. Exit

Enter your choice

Enter item code, name, quantity an price

1 pen 5 20

You can do the following:


1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Enter item code, name, quantity an price

1 eraser 2 12

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Item code item name quantity price Amount

1 pen 5 20 100

2 eraser 2 12 24

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice


4

Final Amount to be paid is Rs.124

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Enter item code of the item to be deleted

101

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Item code item name quantity price Amount

1 pen 0 0 0

2 eraser 2 12 24

You can do the following:

1. Add an item

2. Delete an item

3. Display list
4. Display amount

5. Exit

Enter your choice

Final Amount to be paid is Rs.24

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Invalid choice! Please try again.

You can do the following:

1. Add an item

2. Delete an item

3. Display list

4. Display amount

5. Exit

Enter your choice

Thank you and visit again.

You might also like