+1 (315) 557-6473 

Polymorphic TVs assignment sample

If you are having trouble completing assignments revolving around the concept of polymorphic TVs, contact our experts. They will do these assignments for you so you can have an idea of how to deal with similar tasks in the future.

Polymorphic TVs

Questions on C++

Question 1:
polymorphic 1
polymorphic 2
polymorphic 3

Solution 1:


#include

#include

using namespace std;

#define MOD 1000000007

#define ll long long

#define slld(t) scanf(“%lld”,&t)

#define sd(t) scanf(“%d”,&t)

#define sld(t) scanf(“%ld”,&t)

#define pd(t) printf(“%d\n”,t)

#define plld(t) printf(“%lld\n”,t)

#define pcc pair

#define pp pair

#define pll pair

#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)

#define mp(a,b) make_pair(a,b)

#define F first

#define S second

#define pb(x) push_back(x)

struct TV

{

charscreenType; intscreenSize; string resolution; double price; bool standard;

TV()

{

screenType = ‘L’; screenSize = 50;resolution = “HD”; price = 600; standard = 1;

}

TV setOrder()

{

TV tt = TV();

cout<<“Enter your specifications : “<

cout<<“Enter screenType”<

char p;

cin>>p;

cout<<“Enter screenSize”<

intss;

cin>>ss;

cout<<“Enter resolution”<

string x;

cin>>x;

tt.screenSize = ss;

tt.screenType = p;

tt.resolution = x;

returntt;

}

void display()

{

if(standard==1)

{

cout<<“Standard TV”<

}

else

{

cout<<“Customized TV”<

}

}

doublegetPrice()

{

return price;

}

boolgetStandard()

{

return standard;

}

};

int foo(TV t)

{

intans = 600;

if(t.screenType==’O’)

{

ans += 300;

}

if(t.screenSize>50)

{

int ans1 = (t.screenSize-50)*20;

if(t.screenType==’O’)

{

ans1 *= 2;

}

ans += ans1;

}

if(t.resolution==”UHD”)

{

ans += 200;

if(t.screenType==’O’)

{

ans += 200;

}

}

returnans;

}

void display(TV t)

{

cout<

cout<<“Thanking for using this program”<

}

int main()

{

TV t = TV();

// cout<

t = t.setOrder();

// cout<

intans = foo(t);

cout<<“This will cost you “<

}

Question 2:

polymorphic 3

polymorphic 5

polymorphic 6

polymorphic 7

Solution 2:

#include

#include

using namespace std;

 

#define MOD 1000000007

#define ll long long

#define slld(t) scanf(“%lld”,&t)

#define sd(t) scanf(“%d”,&t)

#define sld(t) scanf(“%ld”,&t)

#define pd(t) printf(“%d\n”,t)

#define plld(t) printf(“%lld\n”,t)

#define pcc pair

#define pp pair

#define pll pair

#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)

#define mp(a,b) make_pair(a,b)

#define F first

#define S second

#define pb(x) push_back(x)

 

class Rental

{

private:

stringshopId; //s1, s2, s3 ….. s10

stringmallId; //m1, m2, m3

int month;

double amount;

public:

Rental(string=” “, string=” “, int = 0, double= 0);

voidsetRental(string x, string y, int a, double b)

{

shopId=x;

mallId=y;

month=a;

amount = b;

}

stringgetShopId()

{

returnshopId;

}

stringgetMallID()

{

returnmallId;

}

intgetMonth()

{

return month;

}

doublegetAmount()

{

return amount;

}

};

 

 

class Consolidation

{

private:

Rental r[50];

intrcount=0;

public:

voidreadFile()

{

// take file input here

// use this method

fstreamdatafile;

datafile.open(“your file name”);

while(!datafile.empty())

{

// take inputs here

datafile>>value;

rcount += value;

// r count is rent for that month

}

}

voidwriteFile(int month)

{

// this will write file to the output location

fstreamdatafile;

datafile.open(“output file name”);

while(!datafile.empty())

{

// write output here

datafile<<“variables”<

datafile<

}

}

};

 

int main()

{

Consolidation s;

s.readFile();

s.writeFile();

}