Quick Links to Application questions (with solutions)!

C++.

Java.

Sunday, January 17, 2010

Words and numbers - Calulation - Adding (with user input) code

import java.util.Scanner;

class bananas
{
public static void main(String args[])
{
Scanner eggs = new Scanner(System.in);
int x, y, ans;
System.out.print("Enter 1st number: ");
x = eggs.nextInt();
System.out.print("Enter 2nd number: ");
y = eggs.nextInt();
System.out.print("Answer: ");
ans = x + y;
System.out.println(ans);
}
}

No comments:

Post a Comment