Computer Science, asked by Yuzineee9301, 25 days ago

Richard Castle wants to buy a shirt. As he is very lazy, he decided to buy the shirt online. He chooses a shirt in Flipkart and is surprised to see the same shirt in Amazon and Snapdeal as well. So he decided to buy the shirt from the website which offers it at the least price. The price of the shirt, discount % and the shipping charges of all three websites have been given as input. Help him in calculating the price of the shirt in each website and decide which website has the lowest price.

Answers

Answered by manishvermabittu
4

Answer:

#include<iostream>

using namespace std;

int main()

{

 int fa,fd,fs,sa,sd,ss,aa,ad,as;

 cin>>fa>>fd>>fs>>sa>>sd>>ss>>aa>>ad>>as;

 int df,ds,da;

 df=(fd/100)*fa;

 ds=(sd/100)*sa;

 da=(ad/100)*aa;

 int tf,ts,ta;

 tf=(fa-df+fs);

 ts=(sa-ds+ss);

 ta=(aa-da+as);

 cout<<"In Flipkart Rs."<<tf<<endl;

  cout<<"In Snapdeal Rs."<<ts<<endl;

  cout<<"In Amazon Rs."<<ta<<endl;

 if((tf<ts)&&(tf<ta))

   cout<<"He will prefer Flipkart";

 else if((ts<tf)&&(ts<ta))

   cout<<"He will prefer Snapdeal";

 else

   cout<<"He will prefer Amazon";

 return 0;

}

Explanation:

Answered by sumitsl
0

The main formula used will be Price - discount% + shipping fee.

Source code:

#include <stdio.h>

#include <conio.h>

void main()
{
clrscr();

int pr[3], disc[3], shipfee[3],i;

float netpr[3],a,b,c;

printf("Enter t-shirt prices on Flipkart, Amazon and snapdeal respectively\n");
for(i=0;i<3;i++)
{
scanf("%d",&pr[i]);
}
printf("Enter discount percentage on Flipkart, Amazon and snapdeal respectively\n");
for(i=0;i<3;i++)
{
scanf("%d",&disc[i]);
}

printf("Enter shipping fees on Flipkart, Amazon and snapdeal respectively\n");
for(i=0;i<3;i++)
{
scanf("%d",&shipfee[i]);
}

for(int i=0;i<3;i++)
{
netpr[i] = pr[i] - ((disc[i]*pr[i])/100) + shipfee[i];
}

a=netpr[0];

b=netpr[1];

c=netpr[2];

if(a<b && a<c)
printf("Richard will buy the shirt from Flipkart at the price: %.2f",a);

else if(b<a && b<c)
printf("Richard will buy the shirt from Amazon at the price: %.2f",b);

else

printf("Richard will buy the shirt from Snapdeal at the price: %.2f",c);

getch();

}

#SPJ2

Similar questions