Question

This one is a little tricky for me. Please put the following pseudocode into C++. Below...

This one is a little tricky for me. Please put the following pseudocode into C++. Below the pseudocode is a header file as well as a cpp file that needs to be included.

// Start
// Declarations
// TermPaper paper1
// string firstName
// string lastName
// string subject
// character grade
// output "Please enter first name. "
// input firstName
// output "Please enter last name. "
// input lastName
// output "Please enter subject. "
// input subject
// output "Please enter letter grade. "
// input grade
// Set the first name for paper1
// Set the last name for paper1
// Set the subject for paper1
// Set the letter grade for paper1
// output "First Name: ", paper1.getFirstName()
// output "Last Name: ", paper1.getLastName()
// output "Subject: ", paper1.getSubject()
// output "Grade: ", paper1.getGrade()
// Stop

Header file is named TermPaper.h that includes the following code:

#include <string>

using namespace std;

#ifndef _TermPaper
#define _TermPaper
class TermPaper
{
private:
   string fName; // first name
   string lName; // last name
   string subject; // subject of the paper
   char letterGrade; // assigned letter grade

public:
   TermPaper( );
   void setFName(string fN);
   void setLName(string lN);
   void setSubject(string sub);
   void setLetterGrade(char grade);
   string getFName( );
   string getLName( );
   string getSubject( );
   char getLetterGrade( );

};
#endif

cpp file is named TermPaper.cpp which includes the following code:
#include <cstdlib>
#include <iostream>
#include "Termpaper.h"

using namespace std;

TermPaper::TermPaper( )
{
fName = "";
lName = "";
subject = "";
letterGrade = 'F';
}
void TermPaper::setFName(string fN)
{
fName = fN;
}
void TermPaper::setLName(string lN)
{
lName = lN;
}
void TermPaper::setSubject(string sub)
{
subject = sub;
}
void TermPaper::setLetterGrade(char grade)
{
letterGrade = grade;
}
string TermPaper::getFName( )
{
return fName;
}
string TermPaper::getLName( )
{
return lName;
}
string TermPaper::getSubject( )
{
return subject;
}
char TermPaper::getLetterGrade( )
{
return letterGrade;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <bits/stdc++.h>
#include "TermPaper.h"
using namespace std;

int main() {
// Start
// Declarations
// TermPaper paper1
TermPaper paper1;
// string firstName
string firstName;
// string lastName
string lastName;
// string subject
string subject;
// character grade
char grade;

// output "Please enter first name. "
cout << "Please enter first name. " << endl;
// input firstName
cin >> firstName;
// output "Please enter last name. "
cout << "Please enter last name. " << endl;
// input lastName
cin >> lastName;
// output "Please enter subject. "
cout << "Please enter subject. " << endl;
// input subject
cin >> subject;
// output "Please enter letter grade. "
cout << "Please enter letter grade. " << endl;
// input grade
cin >> grade;

// Set the first name for paper1
paper1.setFName(firstName);
// Set the last name for paper1
paper1.setLName(lastName);
// Set the subject for paper1
paper1.setSubject(subject);
// Set the letter grade for paper1
paper1.setLetterGrade(grade);

// output "First Name: ", paper1.getFirstName()
cout << "First Name: " << paper1.getFName() << endl;
// output "Last Name: ", paper1.getLastName()
cout << "Last Name: " << paper1.getLName() << endl;
// output "Subject: ", paper1.getSubject()
cout << "Subject: " << paper1.getSubject() << endl;
// output "Grade: ", paper1.getGrade()
cout << "Grade: " << paper1.getLetterGrade() << endl;

// Stop
return 0;
}



Output:

____________________________
Comment down for any queries

Please give a thumb up

Add a comment
Know the answer?
Add Answer to:
This one is a little tricky for me. Please put the following pseudocode into C++. Below...
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
  • Hi, I want to creat a file by the name osa_list that i can type 3...

    Hi, I want to creat a file by the name osa_list that i can type 3 things and store there ( first name, last name, email). then i want to know how to recal them by modifying the code below. the names and contact information i want to store are 200. #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> using namespace std; class Student { private: string fname; string lname; string email;       public: Student(); Student(string fname, string lname,...

  • Java need help with searching for a contact Question:Write a program that uses an ArrayList of...

    Java need help with searching for a contact Question:Write a program that uses an ArrayList of parameter type Contact to store a database of contacts. The Contact class should store the contact’s first and last name, phone number, and email address. Add appropriate accessor and mutator methods. Your database program should present a menu that allows the user to add a contact, display all contacts, search for a specific contact and display it, or search for a specific contact and...

  • Please put the following pseudocode into C++. Below the pseudocode is a header file as well...

    Please put the following pseudocode into C++. Below the pseudocode is a header file as well as a cpp file that needs to be included. // Start // Declarations // Automobile myAuto // string vin // string make // string model // string color // output "Please enter the Vehicle Identification Number: " // input vin // output "Please enter the Make: " // input make // output "Please enter the Mode: " // input model // output "Please enter...

  • I need to change the following code so that it results in the sample output below...

    I need to change the following code so that it results in the sample output below but also imports and utilizes the code from the GradeCalculator, MaxMin, and Student classes in the com.csc123 package. If you need to change anything in the any of the classes that's fine but there needs to be all 4 classes. I've included the sample input and what I've done so far: package lab03; import java.util.ArrayList; import java.util.Scanner; import com.csc241.*; public class Lab03 { public...

  • For the following task, I have written code in C and need help in determining the...

    For the following task, I have written code in C and need help in determining the cause(s) of a segmentation fault which occurs when run. **It prints the message on line 47 "printf("Reading the input file and writing data to output file simultaneously..."); then results in a segmentation fault (core dumped) I am using mobaXterm v11.0 (GNU nano 2.0.9) CSV (comma-separated values) is a popular file format to store tabular kind of data. Each record is in a separate line...

  • The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried t...

    The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

  • JAVA /** * This class stores information about an instructor. */ public class Instructor { private...

    JAVA /** * This class stores information about an instructor. */ public class Instructor { private String lastName, // Last name firstName, // First name officeNumber; // Office number /** * This constructor accepts arguments for the * last name, first name, and office number. */ public Instructor(String lname, String fname, String office) { lastName = lname; firstName = fname; officeNumber = office; } /** * The set method sets each field. */ public void set(String lname, String fname, String...

  • Write a simple telephone directory program in C++ that looks up phone numbers in a file...

    Write a simple telephone directory program in C++ that looks up phone numbers in a file containing a list of names and phone numbers. The user should be prompted to enter a first name and last name, and the program then outputs the corresponding number, or indicates that the name isn't in the directory. After each lookup, the program should ask the user whether they want to look up another number, and then either repeat the process or exit the...

  • This C# program prints out a corresponding letter grade for a given mark. It uses a...

    This C# program prints out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is...

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