Simon Toma
write a program which asks the user for two int values and calculates their sum.
2 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

The title says it all, an example is (1,2) > 3

Advertisement
View Answers

June 2, 2011 at 12:29 PM


import java.util.*;

public class Calculate {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Num1: ");
        int num1 = input.nextInt();
        System.out.print("Num2: ");
        int num2 = input.nextInt();
        if (num1 > 0 && num2 > 0) {
            int sum = num1 + num2;
            System.out.println("Sum= " + sum);
        }
            else {
            System.out.println("Invalid Numbers");
            System.out.println("End of program");
        }
    }
}


April 15, 2013 at 2:01 AM


with java

Write a program to get student grade for 3 different subjects, and display the CGPA for them.

Write a program to read 8 integer numbers from user, put them into 2 matrix A and B(2 by 2), and multiply the matrix and display the result.










Related Tutorials/Questions & Answers:
write a program which asks the user for two int values and calculates their sum.
write a program which asks the user for two int values and calculates their sum.  The title says it all, an example is (1,2) > 3
write a java program for pagination which will be configured by end user
write a java program for pagination which will be configured by end user  write a java program for pagination which will be configured by end user
Advertisements
write a java program for pagination which will be configured by end user
write a java program for pagination which will be configured by end user  write a java program for pagination which will be configured by end user  
write a program to create a user defined
write a program to create a user defined   plz send me code   Hi Friend, Please specify what do you want to create? Thanks
help to write a program for biology to know if two person are related or not
point and end point , i need only help to write the two method which sum rows...help to write a program for biology to know if two person are related... in 2d array but i have wrote program to sum the ones each rows and compared
Write a program that takes the marks of user as input
Write a program that takes the marks of user as input  Write a program that takes the marks of user as input. If marks are greater then 60... not understand how to write a program like this and thank you
Write a C language program to read two matrices and multiply them?
Write a C language program to read two matrices and multiply them?  Write a C language program to read two matrices and multiply them?   ...;stdio.h> #include <conio.h> int main() { int m, n, p, q, c, d, k, sum
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
as selected by the user which is already stored in the DB   Hello, This is for Updating. I had two SQL queries one for only selected values the user has choosen before and the second SQL query to show all the values. Iwas
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB  The below..., this is a update screen where user can go and reselect those values..... plz
sum of all values in a column of jtable
sum of all values in a column of jtable  hey everyone, is there a code to display the sum of all values in a column of a jtable namely CARTtbl... or deleted.   Here is an example of jtable that sums up the values of two
How to compare two tables, and insert values which r not in one table to another table?
How to compare two tables, and insert values which r not in one table to another table?  Hi I need to compare two tables MainTable and OUTTable... is selecting all the values which r not in maintable...but not inserting
Writing and testing method of addition of two numbers
a method named sum() which takes two int parameters and return addition of these two... method which takes two int parameters to add them and return it . Save and compile this file. public class Calculator{   int sum(int
Sum of two Matrix
to this. In this program we are going to calculate the sum of two matrix. To make this program... Sum of  two Matrix       In this section, we are going to calculate the sum of two matrix
Calculating Sum of two Multidim
that will calculate the sum of the matrix. To make this program run we need to declare two multidimensional array of type int. Firstly calculate the length... Sum of Multidimensional Arrays   
Write a program to list all even numbers between two numbers
Write a program to list all even numbers between two numbers... Numbers Example in Java: Here you will learn to write a program for listing out all the even numbers between two numbers. For this first create a class named
how to write this program
how to write this program  Write a program in java which calculates... or numerical grade. You will be submitting TWO versions of this program. Write one...?Ęs GPA. This program should take a student√Ę‚?¨‚?Ęs First Name, Last Name a GPA
write following program
on thread synchronization with examples Q4 WAP that asks the user to input...-cycle? Q10 WAP that asks the user to input 2 string. If the strings are same...write following program  Q1 What is the difference between single
Two user chess game - Applet
Two user chess game  Write a program for a two user chess game(Users must be on different systems)? please send me this source code to my mail id with step by step explanation
write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010
write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010  write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010 if someone can do
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
PLEASE Help me write a Java program which will store, manipulate, and print..., ADDRESS AND ADMISSIONS CLASS PLEASE HELP!!! Write a Java program which..., and Date, where: (a) Name is a user defined class comprising of at minimum first
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
Write a int value into int buffer at given index.
Write a int value into int buffer at given index.  In this tutorial, we will see how to write the given int value into int buffer at the given .... abstract  InttBuffer put(int index, int value) The put(..) method write
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how... the console. Now here is the simple example which will help you to find the sum of odd... number"); Scanner sin; int m,n,sum=0; sin=new Scanner(System.in); n
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
Write Keys and Values to the Properties file in Java
how to write keys and values in the properties files through the Java program. The program for writing keys and values to the properties file has been mentioned... Write Keys and Values to the Properties file in Java
Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... as a user wishes. Print the result up to two places of decimal. Q2: Ask the user
sum
: "); int n=input.nextInt(); int s=1,sum=1; System.out.print("The series : 1+"); for(int i=2;i<=n;i++){ s=(s*10)+i; sum=sum+s; if(i==n){ System.out.print(s
write program - Java Beginners
write program  write a java program that will read the values... main(String[] args) { int array[][] = {{5,6,7},{4,8,9}}; int array1[][] = {{6,4},{5,7},{1,1}}; int array2[][] = new int[3][3]; int x
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers