• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

FBi's running C++ questions

Im, learning it for school and i dont want to miss anything by being caught up in fanciness and i dont ever want to shoot over my lecturers head (am i being presumptuous?). Plus i dont want to get caught up in maneuvering stuff while my programming logic is weak.
 
think of it like a free roam game such as Grand Theft Auto you have an objective but you have multiple ways of completing it some ways will be efficient, some will be inefficient. do not worry about efficiency that takes years of experience but setting a goal or "fanciness" as you call it isn't a bad thing.

- Christine
 
No way to tell if you are being presumptuous. Your instructor could be a programming genious or just know enough to teach the class.

There is no reason that you cannot continue to work within the boundaries of the console window and at the same time study GUI stuff on your own.

Why do you think that your programming "logic" is weak?
Not knowing the nuances of a language does not imply bad logical analysis.
 
i guess its jsut practice .. as my program wasnt functioning properly because of a misunderstanding of how "break" works. i guess ill be gettting a Dietel and dietel and learning.
 
Kreij's posts give me a head ache. lol

what I meant was, for example the snip I posted in this section "parsesnip" was a tool I wrote it was a simple if you have a link list such as:

http://john:doe@members.adultsite1.com/members
http://john:doe@members.adultsite2.com/members
http://john:doe@members.adultsite3.com/members
http://jane:doe@members.adultsite4.com/members
http://chris:tine@members.adultsite5.com/members
http://calv:ary@members.adultsite6.com/members

it will take all the duplicate combinations based on set instances ie 3 which would be "http://john:doe@adultsite*.com/members", sort it and re-write the proper format "john:doe" in the output file.

it was about 106 lines of code, it could of been written by 6 people 6 different ways efficient, inefficient, longer, shorter etc it doesn't matter because the objective of the program would of been accomplished. the big picture is something you should be excited about.

personally i'm very efficient I love taking ideas and making them better. like photoshop which is a system hog would love to create my own version and have it utilize half the resources, compatable plugins and open source that would really piss some people off call it "Adob3 Photoshopz".

anyways im sure Kreij would be excited to do your homework :laugh:

- Christine
 
Last edited:
Not understanding how a language construct (like the break statement) works is normal for anyone who is learning programming. You will run into this again when you are presented with more abstract concepts.

Do not limit what you learn by what your instructor is teaching you.
You do not want to his/her programming habits to define yours.

Sometimes there is a need to have things explained in a variety of ways before you really understand what is going on.

Post and we will do our best to make it "click" for you. :toast:
 
his style is to use "void" functions .. i like to return stuff.

ill pick up a bit more on him as i have shis class some more.
 
you should take me to class, christine the crazy stripper programmer. i'll challenge your teacher see how well he knows his ASM :laugh:

- Christine
 
his style is to use "void" functions .. i like to return stuff..

Keep in mind that if there is no good reason for a function to return a value, then it is just a waste of memory to do so. If you are not going to use the returned value, don't return one.

:toast:

@Christine : My posts give you a headache? I had to peruse your parsesnip post line by line to figure it out! LOL Keep up the good work and the posting !!
 
I was quite impressed

Haven't seen proper use of C++ like that before, most peoples code tends to be poorly laid out and people seem to enjoy reinventing the wheel - whereas you've used the collections and pointers like a pro XD

So where'd you learn to program like that anyway?

Oliver liked it, *bats a scarf around her neck* :p

- Christine
 
LOL .... I was not knocking your code. It was more of a testament to me being rusty when it came to what you were doing. ;)

christine the crazy stripper programmer

I am not sure how to take that statement.
Do you strip out unnecessary code, or code naked? :D
 
both! :o

- Christine
 
LOL ... Thanks Christine, that gave me a good laugh.

I hope that between you, Oliver_FF and I, and anyone else who is willing to help, that we can get IRA to be a coding madman. :toast:

I really appreciate your input to this forum.
I kind of have taken it as my "baby" and I am trying to keep it going strong.
So much good programming info, in any language, that can be shared by people.
 
@Chistine : Sorry, never did like KKs, guess I'm just not a donut lover :)

@IRA : Get back here and post more code so we can help you.
 
Last edited:
Ill have to make more code.

But im hungry too so ill have to make dinner (cant buy, saving for upgrades).

BRB
 
i want to read in a set amount of characters into a variable

char ISBN [13];

how do i do it?
 
It depends on where you are getting the characters from. Give us a little more information.
Is this user input? Is it from another variable? Maybe a file?
 
user input i want to make sure the user inputs only the 13 numbers
 
Read the input into a variable.
Check the length of the string in the variable.
If it is not exaclty 13 characters, throw an error and return them to the input prompt.
 
god bless oliver


i got thsi assignemnt to do

QUESTION ONE
Consider a class named Employee with data members: name and id. All employees have the following behaviour:
(i) setEmployee – sets values to instance variables.
(ii) showEmployee – print the information of the employee
Faculty and Staff are special types of Employees with the additional characteristics of rank and salary for
Faculty and hours, rate and pay for Staff.

Both Faculty and Staff have the following behaviours:
(iii) computePay
For a Faculty member, the salary is calculated as follows based on rank:
o Assistant Professor – 120000
o Associate Professor – 200000
o Professor – 250000
For a Staff member, the pay is based on the rate and hours worked. Overtime is paid time and a half. Overtime is paid after 40 hours.
(iv) updateRnk – appropriate only for Faculty as it updates the rank
(v) updateHrRt – appropriate only for Staff as it updates the hours and the rate
(vi) showEmployee - print the information of the employee (faculty/staff)
(vii) Implement the information above in C++ building appropriate classes.

QUESTION TWO
Create an account class that contains annual interest rate and balance.
The class must contain the following member functions:
a. To calculate monthly interest (Note: Monthly interest is balance multiplied by annual interest rate divided by 12.This monthly interest must be added to existing balance)
b. To modify interest rate that sets the annual interest rate to a new value.
c. To print the account details.
d. Create a constructor with arguments.
In the main function,
• instantiate an object of the class with a balance of $3000.00 and annual interest rate as 7%.
• print the annual interest rate and balance after calculating the monthly interest.
• change the annual interest rate to 4%.

ima do what i can and post what i did
 
question 2

Code:
#include <iostream.h>
#include <conio.h>
#include <string.h>

class account
{
      private:
              float interestRate;
              float balance;
              
      public:
             account(float,float);
             void calculateInterest();
             void setInterestRate();
             void getAccount();
};

account::account(float bal, float in)
{
     balance = bal;
     interestRate = in/100;
}

void account::calculateInterest()
{
     cout << "\nYour new balance after interest calculation is: $" << (1+interestRate)*balance;
     cout << "\nYour current interest rate is: " << (100*interestRate) <<"%";
     cout << "\nYour interest payment for this month is: $" << interestRate*balance;
     
     balance = (1+interestRate)*balance;
}
 
void account::setInterestRate()
{
     float intrate;
     
     cout << "\nEnter the new interest rate in percent: ";
     cin>> intrate;
     
     interestRate = intrate / 100;
}
 
void account::getAccount()
{
     cout << "The current balance is: $" << balance;
     cout << "\nThe current interest rate is: " << interestRate*100<<"%";
}

int main()   
{
    account mine(3000,7);
    
    mine.getAccount();
    mine.calculateInterest();
    mine.setInterestRate();
    
    getch();
    
    return 0;
}
 
Well...flux capacitor,
 
Code:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>

class employee
{
      protected:
              char employeeName [20];
              char employeeIDNumber [10];
              
      public:
             employee();
             void setEmployee();
             void showEmployee();
};

employee::employee()
{
        //Whatever
}

void employee::setEmployee()
{
     cout << "Enter the employees name: ";
     fgets(employeeName, 20, stdin);
     cout << "Enter the employees ID number: ";
     fgets(employeeIDNumber, 10, stdin);
}

void employee::showEmployee()
{
     cout << "\nThe employees name is: " <<employeeName;
     cout << "The employees ID number is: " << employeeIDNumber;
}

class staff:public employee
{
      private:              
              float hours;
              float rate;
              float pay;
      
      public:
             staff();
             void showEmployee();
             void setEmployee();
             void updateHrRt();
             void computePay();
};

staff::staff()
{
     //whatever 
}

void staff::showEmployee()
{
     cout << "\nThe employees name is: " <<employeeName;
     cout << "The employees ID number is: " << employeeIDNumber;
}

void staff::setEmployee()
{
     cout << "Enter the employees name: ";
     fgets(employeeName, 20, stdin);
     cout << "Enter the employees ID number: ";
     fgets(employeeIDNumber, 10, stdin);
}

void staff::updateHrRt()
{
     cout << "Input the new hourly rate: ";
     cin >> rate;
     cout << "Input the hours completed: ";
     cin >> hours;
}

void staff::computePay()
{
     cout << "Enter the amount of hours completed: ";
     cin >> hours;
     cout << "Enter the hourly rate: ";
     cin >> rate;
     
     if (hours > 40)
         pay = ((hours - 40)*(rate * 1.5))+( 40*rate);
     else
         pay = rate * hours;
         
     cout << "Your pay is: " << pay;
}

class faculty:public employee
{
      private:
              int rank;
              float salary;
      public:
             faculty();
             void showEmployee();
             void setEmployee();
             void updateRnk();
             void computePay();
};

faculty::faculty()
{
      //whatever
}

void faculty::showEmployee()
{
     cout << "\nThe employees name is: " <<employeeName;
     cout << "The employees ID number is: " << employeeIDNumber;
}

void faculty::setEmployee()
{
     cout << "Enter the employees name: ";
     fgets(employeeName, 20, stdin);
     cout << "Enter the employees ID number: ";
     fgets(employeeIDNumber, 10, stdin);
}

void faculty::updateRnk()
{
     cout << "Please enter the new rank of " << employeeName;
     cin >> rank;
}

void faculty::computePay()
{
     switch(rank)
     {
         case 1:
              salary = 250000;
              cout << employeeName << ", your salary is: $" << salary;
              break;
              
         case 2:
              salary = 200000;
              cout << employeeName << ", your salary is: $" << salary;
              break;
              
         case 3:
              salary = 120000;
              cout << employeeName << ", your salary is: $" << salary;
              break;
     }
}
     
       

int main()
{
    employee FBi;
    faculty FB;
    
    FBi.setEmployee();
    FBi.showEmployee();
    
    getch();
    
    return 0;
}

part uno
 
Back
Top