Jump to content

JackSewellDev

Member
  • Posts

    5
  • Joined

  • Last visited

Awards

This user doesn't have any awards

About JackSewellDev

  • Birthday Aug 23, 2001

Contact Methods

  • Twitter
    @JackSewellDev

Profile Information

  • Gender
    Male
  • Location
    England
  • Interests
    Programming, Artificial Intelligence, robotics
  • Biography
    I'm a 15 year old who likes to code and make things.

JackSewellDev's Achievements

  1. I'm rather new to C# but I'm learning the basics from http://csharp.net-tutorials.com After I've got a grasp of the basic I'll most likely watch YouTube videos to expand my knowledge.
  2. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearningCSharp { class Program { // The main function static void Main(string[] args) { int total; Console.WriteLine("Please enter your first number: "); // Parses the str into a int and outputs it as number1 int.TryParse(Console.ReadLine(), out int number1); Console.WriteLine("Please enter your second number: "); // Parses the str into a int and outputs it as number2 int.TryParse(Console.ReadLine(), out int number2); total = Maths(number1, number2); Condition(total); Console.WriteLine($"The total of that sum is: {total}"); switch(total) { case 768: Console.WriteLine("Yay! The number was 768!"); break; default: Console.WriteLine("Yay!"); break; } // Exit Console.WriteLine("Press the enter key to exit..."); // Allows the user to see the content and press 'enter' to exit the application Console.ReadKey(); } // Function for adding the two numbers static int Maths(int number1, int number2) { int total = number1 + number2; return total; } // Function for the conditional statements for total static void Condition(int total) { if (total < 100) { Console.WriteLine("Your total is smaller than 100!"); } else if (total > 100) { Console.WriteLine("You total is bigger than 100!"); } else { Console.WriteLine("It seems your number was exactly 100!"); } } } } Learning C# and made this. Nothing huge just a basic console application using some stuff I've learnt.
  3. Looks great! I'm not much of a web developer but your code looks good.
  4. Could you possibly provide a short example? I'm new to C++.
  5. #include "stdafx.h" #include <iostream> #include <string> using namespace std; // Void means the function doesn't return a value to the caller // Int means the function returns a integer value to the caller // adds number_1 and number_2 int add(int x, int y) { cout << x + y << endl; return 0; } // subtracts number_1 and number_2 int subtract(int x, int y) { cout << x - y << endl; return 0; } // divides number_1 and number_2 int divide(int x, int y) { cout << x / y << endl; return 0; } // multiplys number_1 and number_2 int multiply(int x, int y) { cout << x * y << endl; return 0; } int main() { int number_1; int number_2; string operation; cout << "Enter a number: "; cin >> number_1; cout << "Enter another number: "; cin >> number_2; cout << "What operation do you want to do?: "; cin >> operation; // checks if the users typed in "add" and if so adds number_1 and number_2 if (operation == "add") { add(number_1, number_2); } // checks if the users typed in "subtract" and if so subtracts number_1 and number_2 else if (operation == "subtract") { subtract(number_1, number_2); } // checks if the users typed in "divide" and if so divides number_1 and number_2 else if (operation == "divide") { divide(number_1, number_2); } // checks if the users typed in "multiply" and if so multiplys number_1 and number_2 else if (operation == "multiply") { multiply(number_1, number_2); } // if the above checks fail this message will be displayed to the user else { cout << "Please input a valid opeartor!" << endl; // re-runs through the programm main(); } cin.clear(); // reset any error flags cin.ignore(32767, '\n'); // ignore any characters in the input buffer until we find an enter character cin.get(); // get one more char from the user // returns 0 return 0; } Just a simple calculator in C++. Since i'm new to the language it's not the best and can easily be broken but meh it's a start. GitHub link: https://github.com/JackSewellDev/Calculator
×