Simple Decimal Adding

Questions/Tutorials for any programming language not covered in other sections.
1 post Page 1 of 1
Contributors
User avatar
bjm0008
Dedicated Member
Dedicated Member
Posts: 69
Joined: Thu Aug 13, 2009 2:35 am

Simple Decimal Adding
bjm0008
Code: Select all
import java.util.Scanner;
public class Calculator {
	public static void main(String args[]){
		Scanner calc = new Scanner(System.in);
		double Fnum, Snum, Answer;
		System.out.println("Enter First Number Then Press Enter:");
		Fnum = calc.nextDouble();
		System.out.println("Enter Second Number Then Press Enter:");
		Snum = calc.nextDouble();
		Answer = Fnum + Snum;
		System.out.println("Answer: " + Answer);	
	}	
}
Image

I found it easier to relate the java code to VisualBasic code, these were my thoughts:
Double is an integer that has both numbers to the left and right of the deciaml. (such as: 6.7)
Double Fnum, Snum, Answer; is equivelent to Dim Fnum, Snum, Answer as Double in VB

Originally From http://www.youtube.com/thenewboston
Image
1 post Page 1 of 1
Return to “Misc”