+ 1
Test case fail : For the second case my output is 14.44 and should be 14.45 ??
#include <stdio.h> int main () { int no_of_kaleidoscopes; float price, tax, price_with_tax_included, discount, total_price; /*Number of kaleidoscopes purchased */ scanf("%d", &no_of_kaleidoscopes); int cost_of_one_kaleidoscope = 5; price = no_of_kaleidoscopes * cost_of_one_kaleidoscope; tax = 0.07 * price; price_with_tax_included = price + tax; if(no_of_kaleidoscopes <= 1 || no_of_kaleidoscopes == 0) { discount = 0; } else if (no_of_kaleidoscopes > 1) { discount = 0.1 * price_with_tax_included; } total_price = price_with_tax_included - discount; /* Output the total price */ printf("%.2f", total_price); }
2 Respuestas
+ 2
Use double type instead of float. Rounded currectly.
+ 1
Jayakrishna🇮🇳 Thanks.