Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Joao Victor Moura- Assignment 4

IPO
Input Process Output

Weight and Miles Ask the user for weight ,and Shipping charge

distance. Less than or

equal to 10 pounds is $3.00

por 500 miles shipped .More

than 10 pounds but less

than or equal to to 50

pounds is $5.00 per 500

miles shipped. If the

shipping distance is more

than 1000 miles, there is

an additional charge of

$10 per package shipped.

If over 50 pounds ,do not

calculate. Output shipping

charge after calculating

the rate.

Weight / Miles Calculated Rate Shipping Charge

#1 1.5 pounds / 200 miles $3.00 $3.00

#2 5.6 pounds / 1200 miles $3.00 $19.00

#3 11 pounds / 2000 miles $5.00 $30.00

#4 36 pounds / 9600 miles $5.00 $110.00

#5 55 pounds / 645 miles N/A N/A

This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
#6 40 pounds / 3500 miles $5.00 $45.00

CODE

#include <stdio.h>
#include <stdlib.h>
// Joao Victor Moura . I will calculate the shipping charges of each test
according to their weight and mileage //
main() {
double weight, shippingCharge, rate, segments;
int distance;
printf("Enter the weight: \n");
scanf_s("%lf", &weight);
printf("Enter the distance: \n");
scanf_s("%i", &distance);

if (weight > 50.0) {

printf("Sorry, we only ship packages of 50 pounds or less.");

return 0;

}
if (weight <= 10) {
printf("Rate is $3.00 \n");
rate = 3;
}
else {
printf("Rate is $5.00 \n");
rate = 5;
}

if (distance % 500 == 0) {
segments = distance / 500;
}
else {
segments = distance / 500 + 1;
}

This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
shippingCharge = rate * segments;

if (distance > 1000) {


shippingCharge = shippingCharge + 10;
}

printf("Your shipping charge is: $%lf\n", shippingCharge);

system("pause");

My case was weight :40 pounds , miles: 3500 =


The result was a shipping charge of $45.00

Print Screens below

Test #1

This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
Test #2

Test#3

Test #4

This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
Test #5

Test #6

This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
This study source was downloaded by 100000831727298 from CourseHero.com on 03-20-2022 17:05:12 GMT -05:00

https://www.coursehero.com/file/113917380/Assignment-4docx/
Powered by TCPDF (www.tcpdf.org)

You might also like