TOPIC

5% error what is wrong with this code?

Anik Sharif asked 8 months ago

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    double b,d;
    double div[5]={4.00,4.50,5.00,2.00,1.00};

    cin>>a;
    cin>>b;
    b=b*div[a-1];
    cout<<"Total: R$ "<<fixed<<setprecision(2)<<b<<endl;

    return 0;
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Júnior Heleno Ávila replied 8 months ago

    Você não está usando a var d. Ela está inutil ali.

  • Md. Shakiur Rashid Shifat replied 8 months ago

    include

    int main() { int X, Y; float price = 0;

    scanf("%d %d", &X, &Y);
    if (X == 1)
    {
        price  = (float) (4.00 * Y);
    }
    else if (X == 2)
    {
        price  = (float) (4.50 * Y);
    }
    else if (X == 3)
    {
        price  = (float) (5.00 * Y);
    }
    else if (X == 4)
    {
        price  = (float) (2.00 * Y);
    }
    else if (X == 5)
    {
        price  = (float) (1.50 * Y);
    }
    
    printf("Total: R$ %.2f\n",price);

    }