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

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.


April 19, 2017 at 5:31 AM

import java.util.Scanner //Console input rather than JPanes

{

       public static void main(String[] args)
       {
                 Scanner x = new Scanner(System.in);
                 System.out.println("Enter number 1 ");
                 int first = x.nextInt();
                 System.out.println("Enter number 2 ");
                 int second = x.nextInt(); 
                 System.out.println("Enter number 3 ");
                 int third = x.nextInt();
               double GPA = (first + second + third / 3) / 20 ;
                 GPA--; //Equal to GPA = GPA - 1; 
                 System.out.print(GPA);
         }                                                      }









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?ADS_TO_REPLACE_1 Thanks
Create a Program that Calculates Input
Create a Program that Calculates Input   Create a program that takes user input and does a calculation with it, then prints the results back for the user. This could include like a sales tax calculator, or a tip calculator
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 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
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
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
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
Python sum dictionary values by key
Python sum dictionary values by key  Hi, In python we can easily... values. We are getting these two dictionaries from two different web services. We want to merge these dictionaries into one and sum the dictionary values by key
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
|| []).push({}); Q4 WAP that asks the user to input a no. If a no is even... name 1000 times. The other thread calculates the sum of 1st 1000 integers... = window.adsbygoogle || []).push({}); Q10 WAP that asks the user to input 2
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
Merge and sum of two dictionaries
Merge and sum of two dictionaries  Hi, I want to merge the two dictionaries and at the same I want to sum the vales of the same key. How I can achieve this? Thanks   Hi, this is very classical example of summing
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
Sum of two numbers using command line arguments in Java
Sum of two numbers using command line arguments in Java  Hi, How to pass two values as parameter from command line and the get in it Java program? The calculate the sum of two numbers using command line arguments in Java
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
ModuleNotFoundError: No module named 'two-num-sum'
ModuleNotFoundError: No module named 'two-num-sum'  Hi, My Python... 'two-num-sum' How to remove the ModuleNotFoundError: No module named 'two-num-sum' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'two-num-sum'
ModuleNotFoundError: No module named 'two-num-sum'  Hi, My Python... 'two-num-sum' How to remove the ModuleNotFoundError: No module named 'two-num-sum' error? Thanks   Hi, In your python environment
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
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
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
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 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
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
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
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 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
python merge two dictionaries add values
the values (int values) into the merged dictionary. For example student marks in three...,"chemistry":25,"math":29,"english":34} I want to merge and sum the values...python merge two dictionaries add values  Hi, In Python I have two
write a java program to find the summation of all the integers entered on command line
write a java program to find the summation of all the integers entered on command line  Hi, write a java program to find the summation of all the integers entered on command line? How to write Java program for summation of all
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 ...(..) method write the given int value into associated buffer at given index
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
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
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... void find(int[][] arr){ int rows = arr.length; int cols = arr[0
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
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
Java Program - Java Beginners
Java Program  Write a java program to find out the sum of a given number by the user?  Hi Friend, Try the following code: import... num2=input.nextInt(); int sum=num1+num2; System.out.println("Sum of two numbers
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
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
Generate Random Integer Between Two Values in Scala
Generate Random Integer Between Two Values in Scala  Hi, I am working on the SCALA project and want to generate random integer between two numbers. How to Generate Random Integer Between Two Values in Scala? Thanks   
Generate Random Integer Between Two Values in Scala
Generate Random Integer Between Two Values in Scala  Hi, I am working on the SCALA project and want to generate random integer between two numbers. How to Generate Random Integer Between Two Values in Scala? Thanks   

Ads