Overclock.net - An Overclocking Community

Overclock.net - An Overclocking Community (https://www.overclock.net/forum/)
-   Coding and Programming (https://www.overclock.net/forum/142-coding-programming/)
-   -   We lost our programming virginity (https://www.overclock.net/forum/142-coding-programming/565808-we-lost-our-programming-virginity.html)

TheGrayNobleman 08-27-2009 04:08 PM

So Havegooda and I just took our first C++ programming course today
He insisted I posted my code because the instructor went nuts over it (I rewrote it cause I didn't save the file to a google doc like he did so sorry for any errors I might have missed when I would doing a quick type up of this.

I assume Havegooda is gonna post under this so feel free to post code comments/suggestions/questions/rants.

Finds the average of 3 numbers.
Code:
/*
|----------------------------------------------------------------------|
Title: average.cpp
Abstract: This program computes the average of three exams. 
Author: 
ID: 2009                        
Date: 08/27/2009   
|----------------------------------------------------------------------|
*/


//Find average
#include <iostream>
using namespace std;

int main()
{
    cout << "Let's find the average of 3 exam scores" << endl;
    int number1, number2, number3, avg;
    cin >> number1 >> number2 >> number3;
    avg = (number1 + number2 + number3) / 3;
    cout << "The average is " << avg << "!" << endl;
    return 0;
}
Average of 3 scores
Code:
#include <iostream>
using namespace std;
int main()
{
    double score1, score2, score3, average;

    cout << "Enter three scroes ==> " << endl;
    cin >> score1;
    cin >> score2;
    cin >> score3;

    average = (score1 + score2 + score3) / 3;
    cout << "The average is " << average << endl;

    return 0;
}
Posts the tax rate you type
Code:
#include <iostream>
using namespace std;
int main()
{
    double tax_rate;
    cout << "What is your tax rate?" << endl;
    cin >> tax_rate;
    cout << "Your tax rate is " << tax_rate << endl;
    return 0;
}
Find the average and displays a couple of pretty pictures.
Code:
include <iostream>
using namespace std;
void image();
int main()
{
#include <iostream>
using namespace std;
int main()

{
    double score1, score2, score3, average;

    cout << "Enter three scroes ==> " << endl;
    cin >> score1;
    cin >> score2;
    cin >> score3;

    average = (score1 + score2 + score3) / 3;
    cout << "The average is " << average << endl;
    void image;

    return 0;
}

void image()
{
cout << "....." << endl;
cout << "....." << endl;
cout << "....." << endl;
cout << "....." << endl;
cout << "....." << endl << endl;

cout << "  .  " << endl;
cout << " ... " << endl;
cout << "....." << endl;
cout << " ... " << endl;
cout << "  .  " << endl;

system("pause")
}

Havegooda 08-27-2009 04:16 PM

So ya...that was fun.

My first one is just the basic "calculate the average" program we did in class.

Code:
/*
 * Title: lab1_1.cpp
 * Abstract: This program computers average of three exams.
 * Author: Beau Griffin
 * ID: 2328
 * Date: 08/27/09
 */
#include <iostream>
using namespace std;
int main ()
{
    double score1, score2, score3, average;

    cout << "Enter three scores ==> " << endl;
    cin >> score1;
    cin >> score2;
    cin >> score3;

    average = (score1 + score2 + score3);
    cout << "The sum is " << average << endl;

    return 0;
}
Now this one takes the average of three quiz grades and multiplies it by the user's age to give a "random" number to the user.

Code:
/*
 * Title: Random (?) number generator
 * Abstract: This program will generate a number based upon past grades and the user's age
 * Author: Beau Griffin
 * ID: 2328
 * Date: 08/27/09
 */
#include <iostream>
using namespace std;
int main ()
{
    cout << "Enter your last three quiz grades" << endl;
    int quiz1, quiz2, quiz3, age, avg;
    cin >> quiz1 >> quiz2 >> quiz3; //Requests previous grades
    cout << "How old are you?" << endl;
    cin >> age; //Requests age
    avg = (quiz1 + quiz2 + quiz3) / 3; //Computes grade average
    cout << "Your number is " << avg * age << "!\
"; //Computes final number and displays
    return 0;
}
This one takes a subtotal and applies a set amount of tax and gives the final total...
Code:
#include <iostream>
using namespace std;

int main ()
{
    int tax_rate, subtotal;
    cout << "What's the subtotal?" << endl;
    cin >> subtotal;
    cout << "What is your tax rate? e.g. 0.029 for 2.9%" << endl;
    cin >> tax_rate;
    cout << "Your total is " << subtotal * (1 + tax_rate) << "!" << endl;
    return 0;
}
This one is just the "project" we had. It just displays some characters in the console window. Finished it in a few minutes...
Code:
#include <iostream>
using namespace std;
int main ()
{
    cout << "* * * * *" << endl;
    cout << "* * * * *" << endl;
    cout << "* * * * *" << endl;
    cout << "* * * * *" << endl << endl;

    cout << "    *    " << endl;
    cout << "  * * *  " << endl;
    cout << "* * * * *" << endl;
    cout << "  * * *  " << endl;
    cout << "    *    " << endl;

    return 0;
}
Comments on the code?

~Gooda~

Vostro 08-27-2009 04:18 PM

Not bad! Im no programming pro but I did take a C++ course in college. Are you guys using visual basic?

[Teh Root] 08-27-2009 04:18 PM

You guys did some easy stuff. Wait until you get to storage array's writing to and reading files, and sorting letters,numbers and names in C++. It's a hard concept but easy to do, if you pay attention.

Edit: Visual Basic is for Sissies. Use Visual C++ 6.0. That's hardcore stuff. Visual Basic does it for you. Stupid 4th Generation Lanuages.

Drift0r 08-27-2009 04:20 PM

Nice. I actually understood all the programming that you did. It gets interesting and quite fun as you can do more complicated stuff such as manipulating text files and stuff. I only took one year of C++ but I already know quite a lot.

tehmaggot 08-27-2009 04:22 PM

I'm looking forward to my programming classes. I have a messy understanding as to how to get things done, but more disciplined coders would probably laugh at my hack-jobs.

[Teh Root] 08-27-2009 04:24 PM

Yeh. C++ is objectg oriented and on Visual Basic C++ is stupid easy. The fact that it fills in every other line with what you want it to be and it tells you exactly what's wrong with your syntax and logic, takes the frustration and the fun out of Programming.

mrtn400 08-27-2009 04:25 PM

Have you guys actually tested your code yet?

getbigtony 08-27-2009 04:27 PM

woo reminds me of my school days 9 years ago
took like 6 languages; don't remember shiznit!

Havegooda 08-27-2009 04:28 PM

Code worked fine in class, with the possible exception of Noahs last one...he wrote that out of memory without a compiler.

~Gooda~


All times are GMT -7. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
vBulletin Security provided by vBSecurity (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.

vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.