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

Objective: Program for everyday life problems, which requires loops using C++. W

ID: 3701080 • Letter: O

Question

Objective: Program for everyday life problems, which requires loops using C++. Weather (50 points) Write a program to deternine if the weather presenter on your local news is accurate or not Declare an array of 10 integers and initialize them with values representing the actual temperatures for the last 10 days - Have the user enter 10 integers in a separate array that represent the temperatures your weather presenter predicted for the same days. Compare the predicted temperature and actual temperature for the 10 days to determine . the days of the prediction are too low e the days of the prediction are too high, and the days of the prediction are correct. - Display the number of days with low predictions, e the number of days with high predictions, and e the number of days with correct predictions - Display a message that states if the weather presenter is accurate or not .If there are at least three days with correct predictions, the weather presenter is considered as accurate. -Documentation of your program -Save this program as YourIslandID. weather.epp Miles Per Gallon (50 points) Write a program to determine the miles per gallon of a car - Create an array of five strings. The strings will have five different types of cars: . "Sports Coupe", "Sedan SUV" . "Minivan", and ."Pickup" - Create an array to hold the number of miles each of the types of cars can drive on a full tank - Create another array to hold the number of gallons each type of car can hold in its tank - Create an array to hold the miles per gallon for each car based on the previous two procedures by total number of miles / total number of gallons - Determiue and display the type of car with the lowest miles per gallon and the its actual miles per lon ninespay the type of car with the highest males per gallan and the its actual nilies Deterimine and display the type of car with the highest miles per gallon and the its actual miles per gallon value De ocumentation c of your program

Explanation / Answer

ANSWER(1):

#include <iostream>

using namespace std;

int main()
{
   /* Hardcoded temparature value, programmer can edit it as per requirement*/
   float temprature[10] = {22.5,23.5,25.5,24.5,26.7,26.0,27.0,28.0,29.0,30.0};

   // Array to store user input
   float userin[10];
  
   // loop variable
   int i = 0;
  
   // prediciton status counter variable (low,high correct)
   int prediction_low=0,prediction_high =0,prediction_correct = 0;

   // taking user input
   for(i=0;i<10;i++)
   {
       cout<<" Please enter your prediction for day"<<i+1<<" :";
       cin >> userin[i];
   }

   // comparing with actual value and updating status
   for(i=0;i<10;i++)
   {
       if (userin[i] > temprature[i])
       {
           prediction_high =prediction_high+1;
       }
       else if(userin[i] < temprature[i])
       {
           prediction_low = prediction_low +1;
       }
       else
       {
           prediction_correct = prediction_correct +1;
       }
   }

   // printing result
   cout << " RESULT ==>Prediction low = "<<prediction_low << " ==>Prediction high =" << prediction_high;
   cout<< " ==>Prediction correct = "<< prediction_correct << endl;

   // condition check wheather predictor is accurate or not
   if (prediction_correct >= 3)
   {
       cout <<"Wheather predictor is Accurate ";
   }
   else
   {
       cout << ";( Wheather predictor is NOT Accurate " ;
   }

}


/

sample output:

c_chegg$ ./a.out

Please enter your prediction for day1 :10

Please enter your prediction for day2 :60

Please enter your prediction for day3 :20

Please enter your prediction for day4 :60

Please enter your prediction for day5 :30

Please enter your prediction for day6 :60

Please enter your prediction for day7 :27

Please enter your prediction for day8 :28

Please enter your prediction for day9 :29

Please enter your prediction for day10 :30

RESULT
==>Prediction low = 2
==>Prediction high =4
==>Prediction correct = 4
Wheather predictor is Accurate

*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

ANSWER(2):

#include <iostream>

using namespace std;
int main()
{
   // car name as per question
   string car[5] = {"Sports coupe" , "Sedan","SUV","Minivan","pickup"};

   // to store total miles
   float NumberOfMiles[5];
   // to store fule capacity
   float FulesInGallons[5];

   // to store avaerage
   float MilesPerGallons[5];

   // variable to store result index
   int maxResult = 0,minResult = 0;

   //loop variable
   int i=0;

   // taking mile as user input
   for(i=0;i<5;i++)
   {
       cout<<" Enter Number of Miles `"<< car[i]<< "` can drive in full tank: ";
       cin>> NumberOfMiles[i];

   }

   // Taking gallon by user input
   for(i=0;i<5;i++)
   {
       cout<<" Enter Max Gallon fuel can `"<< car[i] << "` hold: ";
       cin>> FulesInGallons[i];
   }

   // calculating average
   for(i=0;i<5;i++)
   {
       MilesPerGallons[i] = NumberOfMiles[i]/FulesInGallons[i];
   }

   // find the index ehich has highest average
   for(i=0;i<5;i++)
   {
       if(MilesPerGallons[i] >MilesPerGallons[maxResult])
       {
           maxResult = i;
       }
   }

   // finding index which has lowest average
   for(i=0;i<5;i++)
   {
       if(MilesPerGallons[i] <MilesPerGallons[minResult])
       {
           minResult = i;
       }
   }

   //printing output
   cout<<" Lowest average: "<<car[minResult]<<" "<< MilesPerGallons[minResult]<<endl;
   cout<<"Highest average: "<<car[maxResult]<<" "<<MilesPerGallons[maxResult]<<endl;
}


/*
OUTPUT:

/a.out

Enter Number of Miles `Sports coupe` can drive in full tank: 10

Enter Number of Miles `Sedan` can drive in full tank: 20

Enter Number of Miles `SUV` can drive in full tank: 30

Enter Number of Miles `Minivan` can drive in full tank: 40

Enter Number of Miles `pickup` can drive in full tank: 50

Enter Max Gallon fuel can `Sports coupe` hold: 10

Enter Max Gallon fuel can `Sedan` hold: 10

Enter Max Gallon fuel can `SUV` hold: 10

Enter Max Gallon fuel can `Minivan` hold: 10

Enter Max Gallon fuel can `pickup` hold: 10

Lowest average: Sports coupe 1
Highest average: pickup 5
                                                         
*/