Calculate Shipping Cost
Tarea
Swipe to start coding
- Create a shipping cost calculator. The initial shipping cost is set at 10% of the product's price.
- If the product's weight exceeds 25 pounds, an additional $2.25 is added to the shipping cost.
- For products weighing over 25 pounds, you have to choose between three delivery options from the slowest to the fastest. Each of these options add an extra cost of $0.3, $0.5, and $1.75, respectively.
- Calculate and display the final shipping cost for the product.
Solución
solution
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
int main()
{
float weight = 27.6;
int option = 2;
float price_of_product = 21.99;
float shipping_price = price_of_product * 0.1;
if (weight > 25)
{
shipping_price += 2.25;
switch (option)
{
case 1:
shipping_price += 0.3;
break;
case 2:
shipping_price += 0.5;
break;
case 3:
shipping_price += 1.75;
break;
}
std::cout << shipping_price << std::endl;
}
}
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 4
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
int main()
{
float weight = 27.6;
int option = 2;
float price_of_product = 21.99;
float shipping_price = ___;
if (___)
{
shipping_price += 2.25;
switch (___)
{
case _:
shipping_price += ___;
break;
case 2:
shipping_price += ___;
___;
case _:
shipping_price += 1.75;
___;
}
std::cout << shipping_price << std::endl;
}
}
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla