My First Java App – Java Programming Reviewed by Momizat on . Yeah so like, I know this isn't really a big deal to most people but I'm starting college in a couple of weeks and wanted to get a head start. So I decided to g Yeah so like, I know this isn't really a big deal to most people but I'm starting college in a couple of weeks and wanted to get a head start. So I decided to g Rating:
You Are Here: Home » Applications » Java Programming » My First Java App – Java Programming

My First Java App – Java Programming

Yeah so like, I know this isn’t really a big deal to most people but I’m starting college in a couple of weeks and wanted to get a head start. So I decided to get a few online tutorials on Java programming and found something perfect.

It’s a set of video tutorials done by a guy named Bucky Roberts on YouTube. The video tutorials are really easy to follow and give you a basic idea of how Java programming works – especially for us newbies. You should check him out! Here is a link to his YouTube channel:

http://www.youtube.com/user/thenewboston

Anyway, after an hour or so of watching his videos and following along, I have managed to somewhat make the backbone of a calculator and blackjack game. No interface or nothing yet, but that’ll come later as I continue watching his videos.

Here is the source code for any of you who care:

import java.util.Scanner;

public class Welcome {
	public static void main(String args[]){

		//User Introduction//
		Scanner input = new Scanner(System.in);
		Calculator calcObject = new Calculator();
		System.out.println("Hi, what is your name?");
		String name = input.nextLine();
		Scanner input2 = new Scanner(System.in);
		System.out.println("Hi, " + name + ". Would you like to use our calulator? <Y/N>");
		String answer = input2.nextLine();
		if (answer.equals("Y"))
		calcObject.calculator(name);
		else if (answer.equals("y"))
			calcObject.calculator(name);
		else if (answer.equals("N"))
			System.out.println("Aww! Okay " + name + ". Goodbye... :(");
		else if (answer.equals("n"))
			System.out.println("Aww! Okay " + name + ". Goodbye... :(");

	}

}

import java.util.*;

public class Calculator {
	public void calculator(String name) {
		char again = 'Y';
		while(again == 'Y' || again == 'y')
		{
		Scanner calc = new Scanner(System.in);
		double fnum, snum, answer = 0;
		String calcu;
		System.out.println("Enter first number(s) for calculation: ");
		fnum = calc.nextDouble();
		System.out.println("What would you like to do? Use one of the following: +,-,* or /");
		Scanner mdsa = new Scanner(System.in);
		calcu = mdsa.next();
		System.out.println("Enter second number for calculation: ");
		snum = calc.nextDouble();
		{
			if (calcu.equals("+")) answer = fnum + snum;
			else if (calcu.equals("-")) answer = fnum - snum;
			else if (calcu.equals("*")) answer = fnum * snum;
			else if (calcu.equals("/")) answer = fnum / snum;
			}
		System.out.println(name + ", the answer to your calculation is: " + answer);

		Scanner response = new Scanner(System.in);
		System.out.print("Would you like to do another calculation? <Y/N>");
		again = response.nextLine().charAt(0);

		}
}

}

Yes it is very basic, but then again I’ve only just started learning Java programming over the last couple of hours, so don’t sue me.

As I continue watching his videos, I’ll update this post with any additions I make to the source code. Hopefully I’ll be able to make a nice looking calculator by the end of it… or at least until I give up! Hehe.

Well yeah. I’m having a lot of fun with this!

Check back later…

Clip to Evernote

About The Author

Number of Entries : 73
Scroll to top