+ Reply to Thread
Results 1 to 8 of 8

Thread: YAY! Joy, read inside!

  1. #1
    dsfreak's Avatar
    dsfreak is offline x10 Elder dsfreak is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Arizona, USA
    Posts
    669

    YAY! Joy, read inside!

    Hey, guess what? I just made my first C# application. I know, you may think first? WOW, I have made like 1000..... Well, I would probably have more if I happened to have had my computer the past few months. Anyhow, it is just a basic program, that I named SIMPLE Calculator. I would like someone (or more) to downlaod it and tell me if I did a good job on my first C# program...... Btw, next up on the line for me is a SIMPLE Web-Browser.


    Thanks!

    File: Simple Calculator Setup

  2. #2
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: YAY! Joy, read inside!

    If you want anyone to actually run it, post the source also.

    Anyways, good job. I recently have been working on learn C++. Although not C, they have a few things in common.

  3. #3
    dsfreak's Avatar
    dsfreak is offline x10 Elder dsfreak is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Arizona, USA
    Posts
    669

    Re: YAY! Joy, read inside!

    Ok, I will edit this with the source. I can see that someone might think there is a virus attached, so, here you go:


    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void btnAdd_Click(object sender, EventArgs e)
            {
                float firstNumber = float.Parse(txtFirstNumber.Text);
                float secondNumber = float.Parse(txtSecondNumber.Text);
                float result = firstNumber + secondNumber;
                lbResult.Text = "The anwser is: " + result.ToString();
            }
    
            private void btnSubtract_Click(object sender, EventArgs e)
            {
                float firstNumber = float.Parse(txtFirstNumber.Text);
                float secondNumber = float.Parse(txtSecondNumber.Text);
                float result = firstNumber - secondNumber;
                lbResult.Text = "The anwser is: " + result.ToString();
            }
    
            private void btnDivide_Click(object sender, EventArgs e)
            {
                float firstNumber = float.Parse(txtFirstNumber.Text);
                float secondNumber = float.Parse(txtSecondNumber.Text);
                float result = firstNumber / secondNumber;
                lbResult.Text = "The anwser is: " + result.ToString();
            }
    
            private void btnMultiply_Click(object sender, EventArgs e)
            {
                float firstNumber = float.Parse(txtFirstNumber.Text);
                float secondNumber = float.Parse(txtSecondNumber.Text);
                float result = firstNumber * secondNumber;
                lbResult.Text = "The anwser is: " + result.ToString();
            }
    
            private void btnClear_Click(object sender, EventArgs e)
            {
                txtFirstNumber.Text = "Cleared!";
                txtSecondNumber.Text = "Cleared!";
                lbResult.Text = "Result: All fields cleared!";
            }
        }
    }
    Edit: This code is released under the GNU Public License. Any attempt to edit and/or republish as your own, or without a refrence back to the author is strictly prohibited.
    Last edited by dsfreak; 10-23-2005 at 05:23 PM.

  4. #4
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: YAY! Joy, read inside!

    Cool, good job.

    What kind of application is that? A windows app, console app, etc.. When I try to compile it, I get an error for the "Using System.[Blah]" parts... I don't knowww..

    Do you know any C++?

    I just made this Friday, it's pretty much the same thing, so I feel like sharing it with you/everyone:

    Code:
    #include <iostream>
    
    class Calculator {
          public:
          int x;
          int y;
          int result;
          int choice;
                
          Calculator();
          void makeChoice();
          void getNumbers();
          void doMath();
          int getResults();
         
    };
    
    Calculator::Calculator() {
      x = 0;
      y = 0;
      choice = 0;                      
    }
    
    
    
    void Calculator::makeChoice() {
        std::cout<< "Which of the following would you like to do? Choose a number." << std::endl;
        std::cout<< "(1) Addition" << std::endl;
        std::cout<< "(2) Subtraction" << std::endl;
        std::cout<< "(3) Multiplication" << std::endl;   
        std::cout<< "(4) Divison" << std::endl;
        std::cout<< "Choice: ";
        std::cin>> choice;
    }
    
    
    void Calculator::getNumbers() {
        std::cout<< "Enter first integer: ";
        std::cin>> x;
        std::cin.ignore();
        std::cout<< "Enter second integer: ";
        std::cin>> y;
        std::cin.ignore();
        std::cout<< "\n    First Number: " << x << std::endl;
        std::cout<< "    Second Number: " << y << "\n" << std::endl;
    }
    
    void Calculator::doMath() {
        switch(choice) {
          case 1:
          result = (x + y);
          break;
         
          case 2:
          result = (x - y);
          break;
         
          case 3:
          result = (x * y);
          break;
         
          case 4:
          result = (x / y);
          break;
        }
    }
    
    int Calculator::getResults() {
      return result;
    }
    
    int main() {
        Calculator calc;
        std::string ynstring;
    do
    {
        calc.makeChoice();
        calc.getNumbers();
        calc.doMath();
        std::cout<< "Result: " << calc.getResults();
        std::cin.get();
        std::cout << "Do another? Yes|No ";
        std::cin>> ynstring;
        std::cout << "\n";
    }
    while(ynstring != "No" && ynstring == "Yes");
        return 0;
    }

  5. #5
    dsfreak's Avatar
    dsfreak is offline x10 Elder dsfreak is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Arizona, USA
    Posts
    669

    Re: YAY! Joy, read inside!

    This is C# code. Also, it is a Windows Application, and needs .NET framework 2.0 BETA (or w/e it is) to run. This is because I am using the free express edition from Microsoft. Unfortunately, since this is only my second acquired code knowledge, I don't know C++, but I heard that they were rather similar.

  6. #6
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: YAY! Joy, read inside!

    Ahh I see, that's why I couldn't compile it, I don't have the .net framework 2 shiz. Hmm.

  7. #7
    dsfreak's Avatar
    dsfreak is offline x10 Elder dsfreak is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Arizona, USA
    Posts
    669

    Re: YAY! Joy, read inside!

    You can download it in like 2-3 minutes from Microsoft. Search Microsoft.com for it. ;-)

  8. #8
    MicrotechXP's Avatar
    MicrotechXP is offline x10 Spammer MicrotechXP is an unknown quantity at this point
    Join Date
    Feb 2005
    Location
    USA,California
    Posts
    3,822

    Re: YAY! Joy, read inside!

    Thats nice but I can not download it. It says your account was suspended.

+ Reply to Thread

Similar Threads

  1. If you don't read, you will get a warning.
    By Corey in forum News and Announcements
    Replies: 11
    Last Post: 12-03-2005, 01:09 AM
  2. Mark Posts Read
    By Bogie in forum Feedback and Suggestions
    Replies: 0
    Last Post: 10-07-2005, 07:23 PM
  3. Table inside table
    By wizeman in forum Tutorials
    Replies: 4
    Last Post: 07-11-2005, 05:56 PM
  4. NEW MEMBERS: Did you read the TOS?
    By n4tec in forum Off Topic
    Replies: 5
    Last Post: 07-06-2005, 01:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers