I need to get this program to display the most expensive value and the most taxed value in text form from the names stored in the array. The following code works out everything apart from displaying the most expensive and most taxed items on the screen. This needs to be done by using if statements. This is using MS Visual Studio using Gwin.
#include "stdafx.h"
#include "gwin.h"
const int MAXITEMS=10;
const int MAXCHARS=30;
char Goods[MAXITEMS][MAXCHARS] = {"StrawberryJam", "Butter", "DVDPlayer", "ChildShoes",
"MP3Player", "Champagne", "WhiteBread", "ChanelNo5", "Shirt", "Kettle"};
int Category[MAXITEMS]={1,1,2,4,2,3,1,3,4,2};
double Price[MAXITEMS]={0.89,0.75,19.2,35.0,14.5, 24.5, 0.95, 30.5, 17.0, 19.2};
int main()
{
double MostExpensive=0, MostTaxed=0;
int i;
int name;
double ivat;
double vat;
double vati;
double fc;
double svat;
double tvat;
int TextValue;
GWindow Gwin;
// Clear the Gwin window
Gwin.clear();
Gwin.setPenColour(BLACK);
Gwin.writeText(10,10,"Name");
Gwin.writeText(150,10,"VAT");
Gwin.writeText(260,10,"Final Cost");
Gwin.writeText(10,270,"Most expensive item is");
Gwin.writeText(10,300,"Most tax charged on");
for(i=0; i<MAXITEMS; i++)
{
Gwin.setPenColour(BLACK);
Gwin.writeText(10,i*20+50,Goods[i]);
if (Category[i]==1)
{
ivat=Price[i]/10;
svat=ivat/2;
vat=ivat+svat;
Gwin.writeDouble(150,i*20+50,vat);
}
if(Category[i]==2)
{
ivat=Price[i]/10;
svat=ivat/2;
tvat=svat/2;
vat=ivat+svat+tvat;
Gwin.writeDouble(150,i*20+50,vat);
}
if(Category[i]==3)
{
ivat=Price[i]/10;
svat=ivat*2;
tvat=ivat/2;
vat=svat+tvat;
Gwin.writeDouble(150,i*20+50,vat);
}
if (Category[i]==4)
{
ivat=Price[i]/10;
svat=ivat/2;
vat=ivat+svat;
Gwin.writeDouble(150,i*20+50,vat);
}
fc=Price[i]+vat;
Gwin.writeDouble(250,i*20+50,fc);
if (fc>MostExpensive)
{
MostExpensive=fc;
}
if(vat > MostTaxed)
{
MostTaxed=vat;
}
}
Gwin.writeDouble(200,270,TextValue);
// Finally, wait for a key to be pressed
Keyboard.waitKey();
return 0;
}