Question

Use C++ Create a Student header file (C++) . Declare the following operations in the file....

  1. Use C++
  2. Create a Student header file (C++) . Declare the following operations in the file.
    1. setName()
    2. setMarks()
    3. setDateOfBirth()
    4. calculateGrade() - This method should compute and return grades based on the mark the student entered
    5. calculateAge() - This method should compute and return age using the DateOfBirth the user entered
    6. displayDetails() - This method should return a string displaying all the details of the user.
  3. Now write the implementation class for the header file.
  4. Now reuse these C++ Code in Python.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

head.h:-

#include<stdio.h>
#include <ctime>
void Setname(char *a){
   printf("enter name: ");
   gets(a); //taking name string from user
}
int Setmarks(){
   int a;
   printf("Enter marks: ");
   scanf("%d",&a); //taking marks from user
   return a;
}
int SetDateOfBirth(int a[]){
   printf("Enter your date of birth:\n");
   printf("Enter day: "); //taking details of date of birth
   scanf("%d",&a[0]);
   printf("Enter Month: ");
   scanf("%d",&a[1]);
   printf("Enter year: ");
   scanf("%d",&a[2]);
}
char calculategrade(int a){ //calculating grade function
   if(a<=100 && a>=90)
       return 'A';
   if(a<=89 && a>=80)
       return 'B';
   if(a<=79 && a>=70)
       return 'c';
   if(a<=69 && a>=60)
       return 'D';
   if(a<=59 && a>=50)
       return 'E';
   else
       return 'F';
}
int calculateage(int a[]){ //calculating age
   time_t now = time(0);
   tm *ltm = localtime(&now); //taking current time using time module
   int year=1900+ltm->tm_year;  
   int month=1+ltm->tm_mon;
   int day=ltm->tm_mday ;
   int monthlist[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //days in each month
   if (a[0] > day) {
day = day + monthlist[a[1] - 1];
month =month - 1;
}
if (a[1] > month) {
year = year - 1;
month = month + 12;
}
int calculateddate = day - a[0];
int calculatedmonth = month - a[1];
int calculatedyear = year - a[2];
printf("\nPresent Age: Years: %d Months: %d Days:"" %d\n", calculatedyear, calculatedmonth, calculateddate);
}
void Displaydetails(){
       char a[50];
   int dob[3];
   Setname(a);
   int marks=Setmarks();
   SetDateOfBirth(dob);
   printf("********** Details *************\n");
   printf("Name :- %s",a);
   printf("\nGrade :- %c",calculategrade(marks));
   calculateage(dob);
  
}

Main.cpp:-

#include<stdio.h>
#include "head.h"
#include<string>

using namespace std;
int main(){
   Displaydetails();
}

output:-

Add a comment
Know the answer?
Add Answer to:
Use C++ Create a Student header file (C++) . Declare the following operations in the file....
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
  • Use C++ to create a class called Student, which represents the students of a university. A...

    Use C++ to create a class called Student, which represents the students of a university. A student is defined with the following attributes: id number (int), first name (string), last name (string), date of birth (string), address (string). and telephone (area code (int) and 7-digit telephone number(string). The member functions of the class Student must perform the following operations: Return the id numb Return the first name of the student Modify the first name of the student. . Return the...

  • This is done in C++ Create an Employee class using a separate header file and implementation...

    This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...

  • IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

    IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • Create a C++ project Create an Employee class using a separate header file and implementation file....

    Create a C++ project Create an Employee class using a separate header file and implementation file. The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours worked and the pay rate. Remember to calculate overtime! Create a...

  • C PROGRAMMING -- Please use simple code QUESTION: - Write a charQueue header file containing all...

    C PROGRAMMING -- Please use simple code QUESTION: - Write a charQueue header file containing all the function headers of following functions: 1- initiateQueue—to initialize a queue 2- enqueue—to add a node at the rear end of the queue 3- dequeue—to remove a node from the front of the queue 4- printQueue—print a queue and an implementation file implementing these functions for a Queue of chars. Inside your main method, which should be part of your tester file, read a...

  • Write a C++ program that includes the following: Define the class Student in the header file Stu...

    Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...

  • I am working in c++. My program requires me to use a header file that is...

    I am working in c++. My program requires me to use a header file that is provided. I must use this header file and create 5 methods: 2 constructors, 2 accessors and this operation* on a 4x4 matrix. Matrix has 16 floating point values that must be entered by user. The Two operator functions: i*t; and t+i, multiply identity (i) matrix by user input value matrix and second function add identity (i) plus user input matrix transform. These two operations...

  • C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to...

    C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to the project. Copy and paste the code is listed below: Design a class named Employee. The class should keep the following information in member variables: Employee name Employee number Hire date // Specification file for the Employee class #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { private:        // Declare the Employee name string variable here. // Declare the Employee...

  • C++ The following task is to be submitted with one Header file that contains all of...

    C++ The following task is to be submitted with one Header file that contains all of the classes and two CPP or source files that contain the function definitions for the classes and the main. 1. Take what we did in class and create a File class for easy reading and writing access. The constructor should take a string and should open a file. 2. Create a function for writing bytes to a file. The function should be a template...

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