Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners write a program which asks the user for two int values and calculates their sum.

Have Programming Question? Ask it here!
 
 
 


Simon Toma
write a program which asks the user for two int values and calculates their sum.
2 Answer(s)      2 years and 11 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
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   
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
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
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
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
A program which converts feet and inches to centimeters.
Java: Exercise - InchesToCm Write a program which converts feet and inches to centimeters. In this application we will write code for converting feet... When you run the example it will show the Swing GUI where user can perform
Programming: Initials 1
________________________________________ Write a program that asks for names and displays the initials. Ask the user for their first name. Save it in a string variable. Ask the user for their last...() method to convert them to upper case. Display the initials to the user
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
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
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
Two Dimensional array program
Two Dimensional array program  consider a two dimensional array... and the first become the last.let the program output elements of the first array...: import java.util.*; public class TDArray { public static void find(int
write a java program
write a java program  write a program to print '*' in a circular form
write a program - Java Beginners
write a program  1. write a program that reads a string composed of 6 words then generate and print a word composed of the first letters of the 6... pqr ghf anm"; String strAr[] = str.split(" "); for(int i=0;i
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
write a program in java.
write a program in java.  arrange the natural n umber in 5x5 matrix...; public class NumberSpiral{ public static void main(String[] args) { int n=5; int i, s = n,x=0, y=0; int arr [][]= new int [n][n]; i=n*n; while(i>=1
write the java program?
write the java program?  1 11 121 1331 14641 15101051
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
write a program to print
write a program to print   write a program to print following 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
getting int values from form and insert it in data base in jsp
getting int values from form and insert it in data base in jsp  how can i get form input such as id convert it to int insert it into database  ... = request.getParameter("formfieldname"); Then convert it into Integer variable: int i
Sum of integers
Sum of integers  A Java program that reads an integer value from the user and displays i) the sum of all even integers between 1 and the input... value both inclusive Example: User enters 7. Sum of even integers = 2+4+6 = 12 Sum
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
Java Sum of Digits
. Following code calculates the sum of digits: while (n > 0) { int p... the sum of multidigit number. For this purpose, we have allowed the user to enter... static void main(String args[]) { int sum = 0; System.out.println("Enter
Dialog I/O: Kilometers to Miles
Java NotesDialog I/O: Kilometers to Miles This basic program asks the user for a number of miles and converts it to kilometers. It uses JOptionPane... dialog boxes from program Source code 1 2 3 4 5
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
Two Dimensional Array Program
Two Dimensional Array Program Using Nested for loop...; program . In this session we will teach how to use of a two dimensional array. First of all we will define a class "Matrix". In this program we
 

 

 

DMCA.com