Hi everyone, I was writing a program and out of the 4 functions, one void function is giving 4 errors that I am not able to understand. The function is : void Conversion(double, double, char).
I am posting my program, including the function that is giving the errors.
I have highlighted the function in red. Any help is appreciated.
#include "stdafx.h"
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
char option, unit;
double minTemp, maxTemp;
void Pattern(void);
double SineWave(void);
void Convert(double,double,char);
void Quit(void);
cout<<"Please select an option from the following menu."<<endl;
cout<<" P[Pattern] S[Sinusoidal] C[Conversion] Q[Quit] "<<endl;
cin>>option;
switch(option)
{
case 'P': case 'p':
void Pattern();
break;
case 'S': case 's':
double SineWave();
break;
case 'C': case 'c':
void Convert(maxTemp, minTemp, unit);
break;
case 'Q': case 'q':
void Quit();
break;
}
return 0;
}
void Pattern()
{
char character;
int numChar;
cout<<"You choosed option P[Pattern]."<<endl;
cout<<"Please enter a character, to display the Pattern."<<endl;
cin>> character;
cout<<"Please enter the number of lines for the character to be displayed."<<endl;
cin>> numChar;
for(character=0; character<numChar; character++)
{
cout<< character<<endl;
}
}
double SineWave()
{
double Voltage = 0.0,time = 1.0, num =0.0;
const double PI = 3.14159265;
const double freq = 1.0;
int i=0;
num = (2*freq*time);
Voltage = sin(num);
for (time= 0; time<1.0; time+= 0.1)
{
cout<<"At time"<<time<<"voltage = "<<Voltage<<endl;
}
return 0;
}
void Convert(double x,double y,char z)
{
double Celcius, Fahrenheit, minTemp, maxTemp;
char tempType,c,f;
cout<<"To convert temperature from Fahrenheit to celcius, press c, and to convert celcius to Fahrenheit to, press f."<<endl;
cin>> tempType;
cout<<"Please enter the range of temperature to be converted(First the maximum and then the minimumseperated by enter)."<<endl;
cin>>maxTemp;
cin>>minTemp;
do
{
if(tempType == 'F'||'f')
Fahrenheit = (9/5)*(Celcius+32);
cout<<Celcius<<"celcius in Fahrenheit= "<<Fahrenheit<<endl;
minTemp++;
}
while(minTemp != maxTemp);
do
{
if(tempType == 'C'||'c')
Celcius = (5/9)*(Fahrenheit-32);
cout<<Fahrenheit<<"Fahrenheit is = "<<Celcius<<endl;
minTemp++;
}while(minTemp != maxTemp);
}
My errors:
Error 1 error C2182: 'Convert' : illegal use of type 'void' c:\users\robogeek\documents\onenote notebooks\elet 2300 (c++)\prog3_bhasin\prog3_bhasin\prog3_bhasin\prog3_bhasin.cpp 49
Error 2 error C2078: too many initializers c:\users\robogeek\documents\onenote notebooks\elet 2300 (c++)\prog3_bhasin\prog3_bhasin\prog3_bhasin\prog3_bhasin.cpp 49
Error 3 error C2360: initialization of 'Convert' is skipped by 'case' label c:\users\robogeek\documents\onenote notebooks\elet 2300 (c++)\prog3_bhasin\prog3_bhasin\prog3_bhasin\prog3_bhasin.cpp 52
Error 4 error C2360: initialization of 'Convert' is skipped by 'case' label c:\users\robogeek\documents\onenote notebooks\elet 2300 (c++)\prog3_bhasin\prog3_bhasin\prog3_bhasin\prog3_bhasin.cpp 52