Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q8. write a program that interacts with the user like this: Write a program that

ID: 3643785 • Letter: Q

Question

Q8. write a program that interacts with the user like this:

Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1, 1994 is day 1 December 31, 1993, is day 365. December 31, 1996, is day 366, since I996 is a leap year. A year is a leap year if it is divisible by four, except that any year divisible by 100 is a leap year only if it is divisible by 400. Your program should accept the month, day, and year as integers. Include a function leap that returns 1 if called with a leap year, 0 otherwise. Write a program that interacts with the user like this: Use the table of emissions limits below to determine the appropriate message.1 Chatflow Wireless offers customers 600 weekday minutes for a flat of 39.99. Night (8 pP.M. to 7 A.M.) and weekend minutes are free, but additional weekday minutes cost 0.40 each. There are taxes of 5.25% on all charges. Write a program that prompts the user to enter the number of weekday minutes, night minutes, and weekend minutes used, and calculates the monthly bill and the input data, the pretax bill and average minute cost, the taxes, and the total bill. Store all monetary values as whole cents (rounding the taxes and average minute cost), and divide by 100 for display of results.

Explanation / Answer

please rate

#include <stdio.h>

int main()
{
    int pollutant;
    float emission;
    long odometerReading;
   
    float co21=3.5,co22=4.5,hc1=0.3,hc2=0.4,no1=0.4,no2=0.5,mhc1=.25,mhc2=0.31;
   
    printf("(1) Carbon monoxide (2) Hydrocarbons (3) Nitrogen oxides (4) Non methane hydrocarbons ");
    printf("Enter pollutant number>> ");
    scanf("%d",&pollutant);
    printf("Enter number of grams emitted per mile>> ");
    scanf("%f",&emission);
    printf("Enter odometer reading>> ");
    scanf("%ld",&odometerReading);
    switch(pollutant)
    {
        case 1:
        {
            if(odometerReading < 50000)
            {
                if(emission > co21)
                    printf("Emission level exceeded permitted level of %f grams / mile ",co21);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",co21);
            }
            else
            {
                if(emission > co22)
                    printf("Emission level exceeded permitted level of %f grams / mile ",co22);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",co22);
            }
            break;
        }
        case 2:
        {
            if(odometerReading < 50000)
            {
                if(emission > co21)
                    printf("Emission level exceeded permitted level of %f grams / mile ",hc1);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",hc1);
            }
            else
            {
                if(emission > co22)
                    printf("Emission level exceeded permitted level of %f grams / mile ",hc2);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",hc2);
            }
            break;   
        }
        case 3:
        {
            if(odometerReading < 50000)
            {
                if(emission > co21)
                    printf("Emission level exceeded permitted level of %f grams / mile ",no1);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",no1);
            }
            else
            {
                if(emission > co22)
                    printf("Emission level exceeded permitted level of %f grams / mile ",no2);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",no2);
            }
            break;
        }
        case 4:
        {
            if(odometerReading < 50000)
            {
                if(emission > co21)
                    printf("Emission level exceeded permitted level of %f grams / mile ",mhc1);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",mhc1);
            }
            else
            {
                if(emission > co22)
                    printf("Emission level exceeded permitted level of %f grams / mile ",mhc2);
                else
                    printf("Emission level did not exceeded permitted level of %f grams / mile ",mhc2);
            }
            break;
        }
    }
    return 0;
}