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

C++ help Xcode #include \"iostream.h\" #include \"fstream.h\" #include \"iomanip

ID: 3838801 • Letter: C

Question

C++ help Xcode

#include "iostream.h"

#include "fstream.h"

#include "iomanip.h"

#include <math.h>

#include "conio.h"

#include <string.h>

using namespace std;

fstream dataFile;

char Anual[5]="";

char *monthSelect(int in)

{

  

switch(in){

  

case 1 : return("January");

  

case 2 : return("February");

  

case 3 : return("March");

  

case 4 : return("April");

  

case 5 : return("May");

  

case 6 : return("June");

  

case 7 : return("July");

  

case 8 : return("August");

  

case 9 : return("September");

  

case 10 : return("October");

  

case 11 : return("November");

  

case 12 : return("December");

  

}

  

return("Not a Valid Choice");

  

}

int readFile()

{

  

if(dataFile==NULL){

  

cout<<" File is empty ";

  

getch();

  

return(1);

  

}

  

return(0);

  

}

class AppWeath

{

  

public:

  

double meanTemp[12];

  

char inMonths[12][20];

  

AppWeath();

  

void dataRetrive(int in)

{

  

strcpy(inMonths[in],monthSelect(in));

  

cout<<" Inoput temperature for "<<inMonths[in]<<" : ?";

  

cin>>meanTemp[in];

  

}

  

void showData(int in)

{

cout<<setw(20)<<setprecision(2)<<setiosflags(ios::left)

  

<<setiosflags(ios::showpoint)

  

<<inMonths[in]<<setw(10)<<setiosflags(ios::right)<<meanTemp[in];

  

}

  

void displaytemp(int vi)

{

cout<<setw(10)<<setprecision(2)<<setiosflags(ios::right)

  

<<setiosflags(ios::showpoint)<<meanTemp[vi];

  

}

  

double returntemp(int vi){

  

return(meanTemp[vi]);

  

}

  

void loadfile();

  

void displaytempscale();

  

  

void updatedata(int in,double vt)

  

{

  

strcpy(inMonths[in],monthSelect(in));

  

meanTemp[in]=vt;

  

}

  

int validate(double vt){

  

if(vt>55 || vt < (-20))

  

return(1);

else

return(0);

  

}

  

};

AppWeath :: AppWeath(){

for(int vi=0;vi<12;vi++)

  

{

  

meanTemp[vi]=0;

  

inMonths[vi][0]=NULL;

  

}

  

}

void AppWeath :: loadfile()

{

dataFile.close();

char myFile[20]="";

  

cout<<"Input the Year: ";

  

cin>>Anual;

  

strcat(myFile,"c:\");

  

strcat(myFile,"data");

  

strcat(myFile,Anual);

  

strcat(myFile,".dat");

  

dataFile.open(myFile,ios::ate|ios::nocreate|ios::in|ios::out|ios::binary);

  

if(dataFile==NULL){

  

char ans;

  

cout<<" File opening Error!!! "

  

<<"Recreate file?(y or n) N : ?";

  

ans=getche();

  

if(ans=='y'|| ans=='Y'){

  

dataFile.open(myFile,ios::ate|ios::in|ios::out|ios::binary);

  

cout<<" File Created Successfully";

  

}

  

else{

  

dataFile;

  

cout<<" File opening Error!!!";

  

}

  

}

  

else if(dataFile!=NULL){

  

cout<<" Data File is successfully loaded";

  

}

  

getch();

  

}

void AppWeath :: displaytempscale(){

  

int vi,c=0;

  

for(vi=1;vi<=70;vi++)

  

{

  

if(vi<=10)

  

cout<<"0";

  

else if(vi<=20)

  

cout<<"1";

  

else if(vi<=30)

  

cout<<"2";

  

else if(vi<=40)

  

cout<<"3";

  

else if(vi<=50)

  

cout<<"4";

  

else if(vi<=60)

  

cout<<"5";

  

else if(vi<=70)

  

cout<<"7";

  

}

  

cout<<" ";

  

for(vi=1;vi<=7;vi++)

  

{

  

for(c=0;c<10;c++)

  

cout<<c;

  

}

  

cout<<" ";

  

}

void top()

{

  

clrscr();

  

cout<<"Weather";

  

getch();

  

}

void main(){

  

char choice='1';

  

int num,vi,j,iNum,totstars=0,state,in;

  

double numDec,dNum,tempHigh=0,tempLow=99999,meanTemp=0,vt;

  

char c;

  

AppWeath mySoftware;

  

dataFile.close();

  

do{

  

clrscr();

  

cout<<"Enter your choice";

  

cout<<"1> Select a Anual to work with "

  

<<"2> Display data as Table "

  

<<"3> Display data as horizontal histogram "

  

<<"4> Display Yearly Statistics to date "

  

<<"5> Record Data "

  

<<"6> Change Data "

  

<<"7> Save Data "

  

<<"0> Exit "

  

<<"Please enter a number (0...7) => ";

  

choice=getche();

  

  

switch(choice){

  

case '0' : top();

  

goto out;

  

case '1' : mySoftware.loadfile();

  

break;

  

case '2' : clrscr();

  

cout<<" *****Display Data as a Table***** ";

  

if(readFile()){

  

goto endtable;

  

}

  

cout<<" Table of Temperature data for "<<Anual;

  

cout<<" ";

  

dataFile.seekg(0,ios::end);

  

num=dataFile.tellg();

  

num=num/sizeof(mySoftware); //num contains how many records previously recorded

  

dataFile.seekg(0,ios::beg);

  

for(vi=1;vi<=num;vi++)

  

{

  

if(vi==1)

  

cout<<" Quater 1 : ";

  

else if(vi==4)

  

cout<<" Quater 2 : ";

  

else if(vi==7)

  

cout<<" Quater 3 : ";

  

else if(vi==10)

  

cout<<" Quater 4 : ";

  

dataFile.read((char *)&mySoftware, sizeof(mySoftware));

  

if(!dataFile.eof()){

  

mySoftware.displaytemp(vi);

  

}

  

dataFile.clear();

  

}

  

getch();

  

endtable:

  

break;

  

case '3' : clrscr();

  

cout<<" *****Display Data as a Horizontal Histogram***** ";

  

if(readFile()){

  

goto endhistogram;

  

}

  

cout<<"Histogram of Temperature data for "<<Anual;

  

mySoftware.displaytempscale();

  

dataFile.seekg(0,ios::end);

  

num=dataFile.tellg();

  

num=num/sizeof(mySoftware);

  

dataFile.seekg(0,ios::beg);

  

for(vi=1;vi<=num;vi++)

  

{

  

cout<<" "<<setw(15)<<setiosflags(ios::left)<<monthSelect(vi);

  

dataFile.read((char *)&mySoftware, sizeof(mySoftware));

  

if(!dataFile.eof()){

  

numDec=mySoftware.returntemp(vi);

  

iNum=floor(numDec);

  

dNum=numDec-iNum;

  

totstars=iNum;

  

if(dNum >= 0.5)

  

totstars++;

  

for(j=1;j<=totstars;j++)

  

cout<<"*";

  

cout<<" "<<totstars;

  

}

  

dataFile.clear();

  

}

  

mySoftware.displaytempscale();

  

getch();

  

endhistogram:

  

break;

  

case '4' : clrscr();

  

cout<<" *****Display Yearly Statistics to Date***** ";

  

if(readFile()){

  

goto endstatus;

  

}

  

cout<<"Temperature Statistics data for "<<Anual;

  

num=dataFile.tellg();

  

num=num/sizeof(mySoftware);

  

dataFile.seekg(0,ios::beg);

  

tempHigh=meanTemp=0;

  

tempLow=99999;

  

for(vi=1;vi<=num;vi++)

  

{

  

dataFile.read((char *)&mySoftware, sizeof(mySoftware));

  

double tmp=mySoftware.returntemp(vi);

  

if(!dataFile.eof()){

  

if(tempHigh < tmp)

  

tempHigh=tmp;

  

if(tempLow > tmp)

  

tempLow=tmp;

  

meanTemp=meanTemp+tmp;

  

}

  

dataFile.clear();

  

}

  

meanTemp=meanTemp/double(num);

  

cout<<" Highest Monthly Average : "<<tempHigh;

  

cout<<" Lowest Monthly Average : "<<tempLow;

  

cout<<" Average Yearly Temperature : "<<meanTemp;

  

getch();

  

endstatus:

  

break;

  

case '5' : clrscr();

  

cout<<" *****Record Data***** ";

  

if(readFile()){

  

goto endRecord;

  

}

  

else{

  

num=dataFile.tellg();

  

num=num/sizeof(mySoftware);

  

if(num==12)

  

cout<<" Data-Entry of "<<Anual<<" is already been done ";

  

for(vi=num+1;vi<=12;vi++)

  

{

  

enteragain:

  

cout<<" Do u wan'vt to enter data for"<<monthSelect(vi)<<" (Y or N) Y : ?";

  

c=getche();

  

if(c=='n' || c=='N')

  

goto endRecord;

  

mySoftware.dataRetrive(vi);

  

if(mySoftware.validate(mySoftware.returntemp(vi)))

  

{

  

cout<<" Invalid Data Entry ";

  

goto enteragain;

  

}

  

cin.get(c);

  

dataFile.write((char *) &mySoftware, sizeof(mySoftware));

  

}

  

}

  

getch();

  

endRecord:

  

break;

  

case '6' : clrscr();

  

cout<<" *****Change Data***** ";

  

if(readFile()){

  

goto endchange;

  

}

  

else{

  

num=dataFile.tellg();

  

num=num/sizeof(mySoftware);

  

tryagain:

  

cout<<" Enter Month (in digit) whose temperature is to be changed : ?";

  

cin>>in;

  

if(in <= 0 || in > num){

  

cout<<" Invalid Month ";

  

getch();

  

goto tryagain;

  

}

  

tempagain:

  

cout<<" Enter Temperature : ?";

  

cin>>vt;

  

if(mySoftware.validate(vt))

  

{

  

cout<<" Invalid Data Entry ";

  

goto tempagain;

  

}

  

dataFile.seekg(0,ios::beg);

  

state= (in-1) * sizeof(mySoftware);

  

dataFile.seekp(state);

  

mySoftware.updatedata(in,vt);

  

cin.get(c);

  

dataFile.write((char *) &mySoftware, sizeof(mySoftware))<<flush;

  

}

  

endchange:

  

break;

  

case '7' : clrscr();

  

cout<<" *****Store the Current Data***** ";

  

if(readFile()){

  

goto endsave;

  

}

  

flush(dataFile);

  

cout<<" Data in Memory is Saved successfully ";

  

getch();

  

endsave:

  

break;

  

default : cout<<" Invalid Input ";

  

getch();

  

}

  

}while(choice!='0');

  

flush(dataFile);

  

dataFile.close();

  

clrscr();

  

out:

  

}

v asd Ge main.cpp G conio.cpp h conio.h G. iomanip.cpp h iomanip.h fstream.cpp h fstream h iostream.cpp h iostream.h Products #include "iostream.h #include "fstream.h" #include "iomanip.h" #include «math.h> #include "conio.h" #include A using namespace std A fstream data File: A char Anual 5 char monthselect nt in switch in case 1 return "January" case 2 eturn "February case 3 return ("March") case 4 return "April case 5 return("May" case 6 return "June case 7 return "July" case 8 return ("August case 9 return "September" case 10 return October case 11 return ("November" case 12 return ("December" return "Not a valid Choice"); int readFile() data File NULL) if cout

Explanation / Answer

fitst thing

change chat ot string----

string monthSelect(int in)
{
  
switch(in){
  
case 1 : return "January";
  
case 2 : return("February");
  
case 3 : return("March");
  
case 4 : return("April");

this code has many errors

but time not sufficient to resolve all those errors

some editors doesn't support conio.h header file because it is not standared c++ file.

remove getch() and execute it

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote