Challenge

Project 1

#include<iostream>

#include<cstdlib>

#include<bits/stdc++.h>

#include <fstream>

using namespace std;

string *commodities = new string[5];

int *cost1=(int *)malloc(10*sizeof(int));

int *cost2=(int *)malloc(10*sizeof(int));

int *qty1=(int *)malloc(10*sizeof(int));

static int c=0;

void comm_fun()

{

int h;

char ch;

ofstream myfile;

myfile.open("example.txt");

do{

cout<<"Enter commodity name";

cin>>commodities[c];

cout<<"Do you want to continue-y/n";

cin>>ch;

c++;

}

while(ch=='y');

cout<<"COMMODITIES ADDED"<<endl;

myfile<<"COMMODITIES ADDED"<<endl;

for(int h=0;h<c;h++)

{

cout<<commodities[h]<<endl;

myfile << commodities[h]<<endl;

}

}

void ven_quo()

{

int k,qty;

ofstream myfile1,myfile2;

myfile1.open("vendor1.txt");

cout<<"Enter venodor1 quotations"<<endl;

myfile2.open("vendor2.txt");

for(k=0;k<c;k++)

{

cout<<commodities[k];

myfile1<<commodities[k];

cin>>qty;

*(cost1+k)=qty;

myfile1<<qty<<endl;

}

cout<<"Enter venodor2 quotations"<<endl;

for(k=0;k<c;k++)

{

cout<<commodities[k];

cin>>qty;

*(cost2+k)=qty;

myfile2<<commodities[k];

myfile2<<qty<<endl;

}

myfile1.close();

myfile2.close();

}

void it_support()

{int k;

string name;

int qty;

int amt1=0,amt2=0;

cout<<"Enter your name";

cin>>name;

for(k=0;k<c;k++)

{

cout<<commodities[k];

cin>>qty;

*(qty1+k)=qty;

amt1=amt1+cost1[k]*qty1[k];

amt2=amt2+cost2[k]*qty1[k];

}

cout<<name;

cout<<"vendor1 quotation"<<amt1<<endl;

cout<<"vendor2 quotation"<<amt2<<endl;

if(amt1>amt2)

cout<<"Get from Vendor2"<<endl;

else if(amt1==amt2)

cout<<"bot quoting same";

else

cout<<"get from vendor1"<<endl;

}

int main()

{

int option=1;

while(option>0){

cout<<"1. Commodities to be purchased"<<endl;

cout<<"2. Enter vendor quotations-v1 &v2"<<endl;

cout<<"3.IT support -calculate buget"<<endl;

cout<<"4.Exit"<<endl;

cin>>option;

int i=0;

if(option==1)

comm_fun();

if(option==2)

ven_quo();

if(option==3)

it_support();

if(option==4)

option=-1;

}

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.