
Alex N. answered 10/28/15
Tutor
5
(8)
Virginia Tech Computer Science and Math Graduate
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// use gcc -o <filename> <filename>.c to compile
// ./<filename> 10 10 to run
// this assumes the weights given are already in kilograms
int main (int argc, char **argv)
{
int firstPack = atoi( argv[1] );
int secPack = atoi( argv[2] );
float firstPackTax = 0.5 * firstPack;
float secPackTax = 0.0;
if(secPack > 10.0) {
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// use gcc -o <filename> <filename>.c to compile
// ./<filename> 10 10 to run
// this assumes the weights given are already in kilograms
int main (int argc, char **argv)
{
int firstPack = atoi( argv[1] );
int secPack = atoi( argv[2] );
float firstPackTax = 0.5 * firstPack;
float secPackTax = 0.0;
if(secPack > 10.0) {
// if secPackage is more than 10 kilos multiply the extra weigh by .75
secPackTax = 10.0 * 0.25 + 0.75 * (secPack - 10.0);
}
else {
secPackTax = secPack * 0.25;
}
float totalTax = firstPackTax + secPackTax;
printf("%.2f\n", totalTax);
return 0;
}
Hope this helps.
secPackTax = 10.0 * 0.25 + 0.75 * (secPack - 10.0);
}
else {
secPackTax = secPack * 0.25;
}
float totalTax = firstPackTax + secPackTax;
printf("%.2f\n", totalTax);
return 0;
}
Hope this helps.