We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

CS201 Introduction to Programming Assignment No 03 Fall 2020 Solution & Discussion

Views: 474

Replies to This Discussion

Share the Assignment Questions & Discuss Here.... 

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

CS201-Assign#3-100%-Correct-Solution

Click on the below link to download the file

CS201-Assign#3-100%-Correct-Solution

CS201_Assignment_No_03_Solution_Fall_2020

Click on the below link to download the file

CS201_Assignment_No_03_Solution_Fall_2020

I need this assignment solution.

Attachments:

CS201 Assignment 3 Fall 2020 Solution idea:

 

Code:

#include <iostream>
#include <fstream>
using namespace std;
class Inventory
{
private:
int itemID;
char itemName[20];
float itemPrice;
float quanitity;
float totalPrice;
public:
void readItems();
void displayItem();
int getItemID();
float getPrice();
float getQuanitiy();
int ret_ItemID();
void updateQuantity(float q);
};
void Inventory::readItems()
{
int price, quantity;
cout "Please enter item ID: ";
getItemID();
cout"Please enter item name: ";
cin>>itemName;
cout"Please enter item price: ";
price=getPrice();
cout"Please enter item quanity: ";
quantity=getQuanitiy();
totalPrice=price*quantity;
}
float Inventory::getPrice()
{
cin>>itemPrice;
return itemPrice;
}
int Inventory::getItemID()
{
cin>>itemID;
return itemID;
}
float Inventory::getQuanitiy()
{
cin>>quanitity;
return quanitity;
}
int Inventory :: ret_ItemID()
{
return itemID;
}
void appendToFile()
{
Inventory obj;
ofstream enter;
enter.open("inventory.txt",ios::app);
obj.readItems();
enter.write(reinterpret_cast<char *> (&obj), sizeof(Inventory));
enter.close();
cout"Inventry record added successfully ";
}
void displayAll()
{
Inventory st;
ifstream inFile;
inFile.open("inventory.txt");
if(!inFile)
{
cout"File could not be open !! press any key.............";
cin.ignore();
cin.get();
return;
}
while(inFile.read(reinterpret_cast<char *> (&st), sizeof(Inventory)))
{
st.displayItem();
coutendl;
}
inFile.close();
cin.ignore();
cin.get();
}
void Inventory::displayItem()
{
cout"ItemID:"itemID;
cout"\tItem Name:"itemName;
cout"\tItem Price:"itemPrice;
cout"\tItemQuantity:"quanitity;
cout"\tTotal Price:"totalPrice;
}
void increaseQuanity(int x)
{
bool found=false;
Inventory std;
float quantity;
fstream file;
file.open("inventory.txt");
if(!file)
{
cout"File could not be open !! Press any key............";
cin.ignore();
cin.get();
return;
}
while(!file.eof() && found==false)
{
file.read(reinterpret_cast<char *> (&std), sizeof(Inventory));
if(std.ret_ItemID()==x)
{
cout"Add Quantity: ";
std.getQuanitiy();
int pos=(-1)*static_cast<int>(sizeof(std));
file.seekp(pos,ios::cur);
file.write(reinterpret_cast<char *> (&std), sizeof(Inventory));
cout"Item Quantity updated successfully"endl;
found=true;
}
}
file.close();
if(found==false)
cout"\n\n Record Not Found ";
cin.ignore();
cin.get();
}
int main()
{
int id;
Inventory obj;
char ch;
do{
cout"ENTER CHOICE\n";
cout"01. ADD AN INVENTORY ITEM\n";
cout"02. DISPLAY FILE DATA\n";
cout"03. INCREASE QUANITY\n";
cout"Please enter your choice: ";
cin>>ch;
switch(ch)
{
case '1': appendToFile();
break;
case '2': displayAll();
break;
case '3': cout"Enter Item ID: ";
cin>>id;
increaseQuanity(id);
break;
case 'y':
break;
default :
cout"Enter valid number"endl;
}
}
while(ch != 'y');
return 0;
}

 

cs201 assignment no 03 solution files in doc and cpp format.

CS201_3_Sol_F20.cpp

CS201_3_Sol_F20.txt

CS201 Assignment No 3 Solution Fall 2020 Complete Correct Solved

CS201 Assignment No. 3 Solution Fall 2020 & 2021 Complete Correct Solved

CS201 Assignment No 3 Solution Fall 2020 Complete Correct Solved

CS201 assignment 3 solution 2021

CS201 assignment 3 solution 2021:

cs201 assignment 3 solution 2020 download

cs201 assignment 3 solution 2021

cs201 assignment 3 solution 2020

cs201 assignment 3 solution

2020 cs201 assignment 3 solution fall 2020

cs201 assignment 3 solution 2020 download

Download PDF file

#cs201_assignment3 #vuhelp #virtualuniversity
CS201 Assignment No.3 Solution||Spring 2020||Virtual University

20/20 marks .

CS201-Assign#3-100%-Correct-Solution

Click on the below link to download the file

CS201-Assign#3-100%-Correct-Solution

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service