Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

CPPS LAB TEST 2

LOBSTERS

#include<stdio.h>
extern char allLobsters[];
void main(void)
{
int i, abCount, eCount;
float saleAmount;

abCount=0;
eCount=0;

for(i=0;i<10;i++)
{
if(allLobsters[i]=='A')abCount++;
if(allLobsters[i]=='B')abCount++;
else if (allLobsters[i]=='E')eCount++;
}

saleAmount=(abCount*11.50)+(eCount*5.50);
printf("Total number of grade A and B lobsters sold:%d\n", abCount);
printf("Total number of grade E lobster sold:%d\n", eCount);
printf(" Total sales of grade A, B and E lobsters:$%.2f\n", saleAmount);
}

TICKETS

#include<stdioh.h>
extern char allTickets[];
void main(void)

{
int a, vipTickets, deluxeTickets;
float totalSales;
vipTickets=0;
deluxeTickets=0;
for(a=0;a<10;a++)
{
if(allTickets[a]=='V')vipTickets++;
else if(allTickets[a]=='A')deluxeTickets++;
else if(allTickets[a]=='B')deluxeTickets++;
}
totalSales=((vipTickets*250.00)+(deluxeTickets*150.00));

printf("Total number of VIP Tickets sold is %d\n",vipTickets);


printf("Total number of Deluxe Tickets sold is %d\n",deluxeTickets);
printf("Total sales is $%2.f\n",totalSales);

MELONS

#include<stdio.h>
void main(void)
{
int m, cCount=0; deCount=0;
float totalSales;

for(m=0; m<10; m++)


{
if(allMelons[m]=='D')||(allMelons[m]=='E'))
{
deCount++;
}
}

totalSales=(cCount*450.00)+(deCount*150.00);

printf("Total number of grade C melons sold:%d\n"), cCount);


printf("Total number of grade D and E melons sold:%d\n",deCount);
printf("Total sale amount of grade C,D, and E melons :%2f\n"), totalSales);
}

BALLS

#include<stdio.h>
extern char allinPockets[];
void main(void)
{
int i, rgCount, byCount;
float totalScore;
rgCount=0;
byCount=0;
for(i=0;i<10;i++)
{
if(allinPockets[i]=='R'||allinPockets[i]=='G')
rgCount++;

else if(allinPockets[i]=='B'||allinPockets[i]=='Y')
byCount++;
}
totalScore=rgCount*2.5+rgCount*3.5;
printf("total number of red and green balls%.d\n",rgCount);
printf("total number of ble and yellow balls:%.d\n",byCount);
printf("total score earned from red,green,blue and yellow balls:
%.4f\n",totalScore);

You might also like