I am working on this switch program everything seems to be ok
but the compiler is giving me an error on the final closing brace
and wanted to know where I am making an error
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int choice;
char repeat;
double MidTerm = 0;
double FinalExam = 0;
double Quiz1 = 0;
double Quiz2 = 0;
double
MidTermGrade = 1,
FinalExamGrade = 2,
Quiz1Grade = 3,
Quiz2Grade = 4,
quit= 5;
cout<<"Please select from the menu choices below.\n";
cout<<"Enter the corresponding number with the grade";
cout<<" you would like to perform.\n";
cout<<"1. MidTermGrade\n";
cout<<"2. FinalExamGrade\n";
cout<<"3. Quiz1Grade\n";
cout<<"Quiz2Grade\n";
cout<<"4. Quit\n";
cin>>choice;
switch (choice) {
case 1:
cout << "Please enter MidTerm Grade.\n";
cin >>MidTermGrade;
MidTermGrade = MidTerm * 50/100;
cout << "The MidTerm Grade " << MidTerm << "."
<< endl;
break;
case 2:
// input to calculate a rectangle
cout<<"Please enter FinalExamGrade.\n";
cin>>FinalExamGrade ;
FinalExamGrade = FinalExam * 50/100;
cout<<"The FinalExamGrade is
"<<FinalExamGrade<<"."<<endl;
break;
case 3:
// input to calculate a triangle
cout<<"Please enter Quiz1Grade\n";
cin>>Quiz1Grade;
Quiz1Grade = Quiz1Grade * 25/100;
cout<<"The
Quiz1Grade"<<Quiz1Grade<<"."<<endl;
break;
case 4:
cout<<"Please enter Quiz2Grade\n";
cin>>Quiz2Grade;
Quiz2Grade = Quiz2Grade * 25/100;
cout<<"The
Quiz2Grade"<<Quiz2Grade<<"."<<endl;
case 5:
cout<<"you have opted to exit the program\n";
break;
default:
// input to tell user the input is invalid
cout<<" Invalid entry, try again";
break;
}
cout<<"press any key to repeat program\n";
cin>> repeat;
}
return 0;
Every thing u have written is correct.But the error u made i instead of keeping final '}' at the end of the programm means after return 0 you placed '}' before return 0.so remove the '}' before return 0 and make sure that the brace should be after the return 0.
like:
return 0 ;}
I am working on this switch program everything seems to be ok but the compiler is...
(C++) I need to alter the code below to fit the given requirements. You will need to move the calculations to a function. A second function to return the Letter Grade. You will need to define a namespace to contain the CONST. Also, need to define an enum for letter grades: A, B, C, D, and F. Console Student Grade Calculation Form First Name: Larry Last Name: Hobbs Homework Average: 65 Midterm Grade: 90 Final Exam Grade: 75 Student: Larry...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points. At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the...
This is my code for a final GPA calculator. For this assignment, I'm not supposed to use global variables. My question is: does my code contain a global variable/ global function, and if so how can I re-write it to not contain one? /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Title: Final GPA Calculator * Course Computational Problem Solving CPET-121 * Developer: Elliot Tindall * Date: Feb 3, 2020 * Description: This code takes grades that are input by the student and displays * their...
Hello i am having a bit of trouble with a verified exit for my program. For some reason when trying to exit it loops to the team selection function? C++ Visual Studio 2017 #include "cPlayer.h" char chChoice1 = ' '; char chChoice3 = ' '; cPlayer::cPlayer() { } cPlayer::~cPlayer() { } void cPlayer::fMenu() { char chChoice3 = ' '; do { cout << "\n\t--Menu--" << endl; cout << "1) Enter Player Name" <<...
The switch Statement C++program This lab work with the switch statement. • Remove the break statements from each of the cases. What is the effect on the execution of the program? • Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output. Sample Run: What grade did you earn in Programming I? YOU PASSED! An A - excellent work! The following is...
I need MIPS code for this program Translate the following C++ program to MIPS assembly program (Please explain each instruction of your code by a comment and submit a .asm file) // Example program #include <iostream> #include <string> using namespace std; int main() { const int ADULT_CHOICE= 1, CHILD_CHOICE= 2, SENIOR_CHOICE= 3, QUIT_CHOICE= 4, ADULT = 250, CHILD = 200, SENIOR = 350; int choice, months; int charges = 0; do { cout <<"\n\t\tHealth Club Membership Menu\n\n" <<"1. Standard Adult...
I am trying to run this program in Visual Studio 2017. I keep getting this build error: error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". 1>Done building project "ConsoleApplication2.vcxproj" -- FAILED. #include <iostream> #include<cstdlib> #include<fstream> #include<string> using namespace std; void showChoices() { cout << "\nMAIN MENU" << endl; cout << "1: Addition...
C++ Check Book Program I need to have a checkbook program that uses the following items. My code that I have appears below. 1) Math operations using built-in math functions 2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template. 3) Binary File #include <iostream> using namespace std; int main() { double checking,savings; cout<<"Enter the initial checking...