Question
Use C++ and must be abke to compile on Visual Studios

9:27 ToDo Final Exam Grade Detail You need to implement C++ code that will read data from a file and process it as outlined b
9:27 KTo Do Final Exam DetailSubmissionGrade Write two functions called convertFtoC and convertCtoF for performing the conver
9:27 くFinal Exam Sampleinput.txt 50 Celsius 5 Celsius 8 Celsius 50 Fahrenheit 80 Fahrenheit 10 Last Dashboard Calendar To Do
9:27 くFinal Exam SampleOutput-1.txt 50 Celsius 122 Fahrenheit 5 Celsius 41 Fahrenheit 8 Celsius 46.4 Fahrenheit 50 Fahrenheit
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go this code and let me know if u need any changes in this.Thank You
_________________

SampleInput.txt

50 Celsius
5 Celsius
8 Celsius
50 Fahrenheit
80 Fahrenheit
10 Last

____________________

#include <fstream>

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

//Declaring constants

const double FCR = 0.556;

const double CFR = 1.8;

//function declarations

double convertFtoC(double f);

double convertCtoF(double c);

int main() {

int cnt=0;

double temp;

string tempType;

//defines an input stream for the data file

ifstream dataIn;

  

//Defines an output stream for the data file

ofstream dataOut;

//Setting the precision

dataOut<<setprecision(1)<<fixed<<showpoint;

  

//Opening the input file

dataIn.open("SampleInput.txt");

//checking whether the file name is valid or not

if(dataIn.fail())

{

cout<<"** File Not Found **";

return 1;

}

else

{

  

while(dataIn>>temp>>tempType)

{

cnt++;

}

//Closing the intput file

dataIn.close();

  

// Creating array dynamically

double* temps = new double[cnt];

// Creating array dynamically

string* tempsType = new string[cnt];

  

//Opening the input file

dataIn.open("SampleInput.txt");

for(int i=0;i<cnt;i++)

{

dataIn>>temp>>tempType;

temps[i]=temp;

tempsType[i]=tempType;

}

//Closing the intput file

dataIn.close();

  

//creating and Opening the output file

dataOut.open("SampleOutput.txt");

for(int i=0;i<cnt;i++)

{

if(tempsType[i].compare("Celsius")==0)

{

dataOut<<temps[i]<<" "<<tempsType[i]<<" "<<convertCtoF(temps[i])<<" Fahrenheit"<<endl;

}

else if(tempsType[i].compare("Fahrenheit")==0)

{

dataOut<<temps[i]<<" "<<tempsType[i]<<" "<<convertFtoC(temps[i])<<" Celsius"<<endl;

}

}

//Closing the output file.

dataOut.close();

}

return 0;

}

double convertFtoC(double f)

{

return FCR * (f - 32.00);

}

double convertCtoF(double c)

{

return CFR * c + 32.00;

}

______________________

OutputFile:

SampleOutput.txt

//img.homeworklib.com/questions/e9d14850-ba9e-11eb-b071-a7e25ce0d923.png?x-oss-process=image/resize,w_560

_______________Thank You

Add a comment
Know the answer?
Add Answer to:
Use C++ and must be abke to compile on Visual Studios 9:27 ToDo Final Exam Grade...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this Final program you are going to use several concepts you learned in CSC 101...

    In this Final program you are going to use several concepts you learned in CSC 101 class, especially operations on or using FILES , LOOPS and FUNCTIONS. You need to implement C++ code that will read data from a file and process it as outlined below and write the processed data to an output file. You can refer to the file input.txt for how the data is made available to you and output.txt for how to write out the processed...

  • C++ requirements All values must be read in as type double and all calculations need to...

    C++ requirements All values must be read in as type double and all calculations need to be done using type double. For part 2 you MUST have at least 4 functions, including main. The main function will be the driver of the program. It needs to either do the processing or delegate the work to other functions. Failure to follow the C++ requirements could reduce the points received from passing the tests. General overview This program will convert a set...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment...

    Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...

  • Use Octave 5:04 < Back HW06-Ch04.doc Homework Assignment #6 Due Date: 04/24/2020 Late Penalty: 10%/day +)(45%)...

    Use Octave 5:04 < Back HW06-Ch04.doc Homework Assignment #6 Due Date: 04/24/2020 Late Penalty: 10%/day +)(45%) Use of the if-elseif-else statements. Given the following function: lag) for 10 (30%) Use Octave to define a function called myFun01. The function myFun01 should take x as an argument and return y to the caller. b.(15%) Use the function you defined in Parta) to compute y using Octave for three different values of XX=-10, x=5,x= 10. You should not use any of the...

  • package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...

    package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...

  • NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a...

    NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a program that asks the user to enter a U.S. dollar amount and then shows how to pay that amount using the smallest number of $20, $10, $5 and $1 bills. Save the file as dollarAmountToNotesFirstinitialLastname.c Sample output: Enter a dollar amount: 93 $20 bills: 4 $10 bills: 1 $5 bills: 0 $1 bills: 3 Hint: Divide the amount by 20 to determine the number...

  • C++ requirements The store number must be of type unsigned int. The sales value must be...

    C++ requirements The store number must be of type unsigned int. The sales value must be of of type long long int. Your program must properly check for end of file. See the section Reading in files below and also see your Gaddis text book for details on reading in file and checking for end of file. Your program must properly open and close all files. Failure to follow the C++ requirements could reduce the points received from passing the...

  • Can you give me this program working in C++ please 95% oo H20 LTE 9:01 PM...

    Can you give me this program working in C++ please 95% oo H20 LTE 9:01 PM ehacc hacc.edu HACC-Harrisburg Area Community Fahringer College CPS 161 Computer Science Program #7 20 points Program Due: Monday, March 21st Word Series Task: Write a program that displays the contents of the Teams txt file on the screen and prompts the user to enter the name of one of the teams. The program should then display the number of times that team has won...

  • Does any one can show me the code in C++ ll cricket LTE 80% 16:58 Back...

    Does any one can show me the code in C++ ll cricket LTE 80% 16:58 Back P2.B MYString v1 Detail Submission Grade For this program, your MYString variables will never need to grow beyond length 20, in program 3 you will need to be allow your string that is held in the class to be able to be larger than 20 chars. So you may want to start allowing your strings to be able to grow....if you have extra time....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT