Thread: C++ program

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    C++ program

    Develop your own class and use it in a program.
    > instantiate object of new class
    > initialize object’s initial values
    > set object’s values
    > print object’s values
    > test the integrity of class by trying to set invalid object values

    1. Create the header file in figure 9.1.
    2. Create the program file in figure 9.3.
    2. Compile the programs.
    3. Run the program.
    4. Capture the results.

    Specifications: Part II

    Discussion:

    For part II, you will get some practice creating classes/header files and using them.

    Specifications:

    1. Use the class developed in Part I.
    2. Create another header file for a date class.
    3. Create another header file for a scores class.
    4. Write an interactive C++ program;
    > instantiate objects of time, date, and scores class
    > prompt the user for date and store it
    > prompt the user for time and store it
    > prompt the user for name of student and store it
    > prompt the user for student id number and store it
    > prompt the user for score and store it
    > the only valid scores are 0 -150
    > the main logic of your program must be included within a loop that repeats until the user decides he/she does not want to continue processing students scores.
    > when the user is done e//Scores.cpp
    //Scores class member function definitions
    Code:
    #include <iostream>
    #include <iomanip>
    #include <string>
    #include "Scores.h"
    using namespace std;
    
    Scores::Scores()
    {
    	lastName, firstName = " ";
    	score = 0;
    }
    
    void Scores::getFirstNameFromUser()
    {
    	string firstName;
    
    	cout << "Enter student's first name: " << endl;
    	cin >> firstName;
    	setFName(firstName);
    }
    
    string Scores::getFirstName()
    {
    	return firstName;
    
    }
    
    void Scores::getLastNameFromUser()
    {
    	string lastName;
    
    	cout << "Enter student's last name: " << endl;
    	cin >> lastName;
    	
    }
    
    void Scores::getScoreFromUser()
    {
    	int score;
    
    	cout << "Enter student's score: " << endl;
    	cin >> score;
    }
    
    void Scores::getDateTime()
    {
    	int month, day, year;
    	int hour, minute, second;
    
    	cout << "Enter month: " << endl;
    	cin >> month;
    	cout << "Enter day: " << endl;
    	cin >> day;
    	cout << "Enter year: " << endl;
    	cin >> year;
    	//Date studentDate( month, day, year);
    
    	cout << "Enter hour: " << endl;
    	cin >> hour;
    	cout << "Enter minute: " << endl;
    	cin >> minute;
    	cout << "Enter second: " << endl;
    	cin >> second;
    	//Time studentTime (hour, minute, second);
    }
    
    void Scores::printScore()
    {
    	cout << "Student's name: " << getFirstName() << " " << endl;//<< lastName 
    		//<< "   score " << score << endl;
    
    	//cout << "Student's name: " << scores.getFirstName << " " << lastName 
    	//	<< "   score " << score << endl; //<< "   date and time  " << studentDate.printDate();
    		//month << "/" << day << "/" << year << "  " << hour << ":" << minute << ":" << second;
    		//<< "  " << studentTime.printTime();
    }
    
    void Scores::setFName(string fname)
    {
    	firstName = fname;
    }
    
    void Scores::setLName(string lname)
    {
    	lastName = lname;
    }
    
    void Scores::setScore(int inScore)
    {
    	score = inScore;
    }
    
    void Scores::setDateTime(int mon, int day, int yr, int hr, int min, int sec)
    {
    	//lastName = lname;
    }
    ntering scores, print out all student IDs, names, scores, date and time of entry
    Last edited by Salem; 06-01-2010 at 09:57 AM. Reason: Added [code][/code] tags - learn to use them yourself

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And your question is...?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    And the code tags are where?

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Sorry but you can't just do:
    • Here is my task.
    • Here is what I've done.
    • Fix it for me.
    We don't do that!

    Your job is to make sure your program conforms to the requirements, and your job is to tell us exactly what is wrong that you can't fix on your own.
    Until you detail any problems, we wont be detailing any solutions, in fact most of us wont even start looking at it yet.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM