SlideShare una empresa de Scribd logo
1 de 4
Descargar para leer sin conexión
CODE:
import java.util.*;
public class test {
public static void main(String args[]) {
int num, sum=0;
Scanner input=new Scanner(System.in);
System.out.print("Input num : ");
num=input.nextInt();
while(num != 13) {
sum=sum+num;
System.out.print("Input num : ");
num=input.nextInt();
}
sum=sum+num;
System.out.println("Sum = "+sum);
}
}
save the above file as test.java
Output:
javac test.java
java test
Input num :
1
Input num :
2
Input num :
3
Input num :
4
Input num :
5
Input num :
6
Input num :
7
Input num :
8
Input num :
9
Input num :
0
Input num :
13
Sum = 58
Solution
CODE:
import java.util.*;
public class test {
public static void main(String args[]) {
int num, sum=0;
Scanner input=new Scanner(System.in);
System.out.print("Input num : ");
num=input.nextInt();
while(num != 13) {
sum=sum+num;
System.out.print("Input num : ");
num=input.nextInt();
}
sum=sum+num;
System.out.println("Sum = "+sum);
}
}
save the above file as test.java
Output:
javac test.java
java test
Input num :
1
Input num :
2
Input num :
3
Input num :
4
Input num :
5
Input num :
6
Input num :
7
Input num :
8
Input num :
9
Input num :
0
Input num :
13
Sum = 58

Más contenido relacionado

Similar a CODEimport java.util.; public class test { public static voi.pdf

Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
anupamfootwear
 
Throwing.javaimport java.util.InputMismatchException; import jav.pdf
Throwing.javaimport java.util.InputMismatchException; import jav.pdfThrowing.javaimport java.util.InputMismatchException; import jav.pdf
Throwing.javaimport java.util.InputMismatchException; import jav.pdf
aquazac
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
Katecate1
 

Similar a CODEimport java.util.; public class test { public static voi.pdf (15)

MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
Oot practical
Oot practicalOot practical
Oot practical
 
Java programs
Java programsJava programs
Java programs
 
Codeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdfCodeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdf
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 
Throwing.javaimport java.util.InputMismatchException; import jav.pdf
Throwing.javaimport java.util.InputMismatchException; import jav.pdfThrowing.javaimport java.util.InputMismatchException; import jav.pdf
Throwing.javaimport java.util.InputMismatchException; import jav.pdf
 
Java -lec-5
Java -lec-5Java -lec-5
Java -lec-5
 
LAB1.docx
LAB1.docxLAB1.docx
LAB1.docx
 
3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf
 
9)Answerimport java.util.; import java.lang.; import java.pdf
9)Answerimport java.util.; import java.lang.; import java.pdf9)Answerimport java.util.; import java.lang.; import java.pdf
9)Answerimport java.util.; import java.lang.; import java.pdf
 
Java practical
Java practicalJava practical
Java practical
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 

Más de anurag1231

a. The alleles are as followsaa - AlbinismAa AA - Normal pigm.pdf
a. The alleles are as followsaa - AlbinismAa  AA - Normal pigm.pdfa. The alleles are as followsaa - AlbinismAa  AA - Normal pigm.pdf
a. The alleles are as followsaa - AlbinismAa AA - Normal pigm.pdf
anurag1231
 
49) sensation is what we receive through senses and perception is wh.pdf
49) sensation is what we receive through senses and perception is wh.pdf49) sensation is what we receive through senses and perception is wh.pdf
49) sensation is what we receive through senses and perception is wh.pdf
anurag1231
 
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
anurag1231
 
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
anurag1231
 
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
anurag1231
 
(1) CA genetic model organism needs to have all the above features.pdf
(1) CA genetic model organism needs to have all the above features.pdf(1) CA genetic model organism needs to have all the above features.pdf
(1) CA genetic model organism needs to have all the above features.pdf
anurag1231
 
The anion is a good leaving group because it is p.pdf
                     The anion is a good leaving group because it is p.pdf                     The anion is a good leaving group because it is p.pdf
The anion is a good leaving group because it is p.pdf
anurag1231
 

Más de anurag1231 (20)

a. The alleles are as followsaa - AlbinismAa AA - Normal pigm.pdf
a. The alleles are as followsaa - AlbinismAa  AA - Normal pigm.pdfa. The alleles are as followsaa - AlbinismAa  AA - Normal pigm.pdf
a. The alleles are as followsaa - AlbinismAa AA - Normal pigm.pdf
 
9933Solution9933.pdf
9933Solution9933.pdf9933Solution9933.pdf
9933Solution9933.pdf
 
49) sensation is what we receive through senses and perception is wh.pdf
49) sensation is what we receive through senses and perception is wh.pdf49) sensation is what we receive through senses and perception is wh.pdf
49) sensation is what we receive through senses and perception is wh.pdf
 
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
1. INTRODUCTIONWe are currently living in the so-called informatio.pdf
 
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
1. d.) Organisms using oxygenic photosynthesis release oxygen into t.pdf
 
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
1. All RTKs have a similar molecular architecture, with a ligand-bin.pdf
 
1)we can see the universe mostly in the form hydrogen and helium. .pdf
1)we can see the universe mostly in the form hydrogen and helium. .pdf1)we can see the universe mostly in the form hydrogen and helium. .pdf
1)we can see the universe mostly in the form hydrogen and helium. .pdf
 
1)D. Bacteria.2)B. Nuclear envelope3)A. Similar in function and .pdf
1)D. Bacteria.2)B. Nuclear envelope3)A. Similar in function and .pdf1)D. Bacteria.2)B. Nuclear envelope3)A. Similar in function and .pdf
1)D. Bacteria.2)B. Nuclear envelope3)A. Similar in function and .pdf
 
1) Pen R contains penicillin resistance gene .Usually + or - is not .pdf
1) Pen R contains penicillin resistance gene .Usually + or - is not .pdf1) Pen R contains penicillin resistance gene .Usually + or - is not .pdf
1) Pen R contains penicillin resistance gene .Usually + or - is not .pdf
 
0.8726Solution0.8726.pdf
0.8726Solution0.8726.pdf0.8726Solution0.8726.pdf
0.8726Solution0.8726.pdf
 
UV radiation has shorter wavelength than visible .pdf
                     UV radiation has shorter wavelength than visible .pdf                     UV radiation has shorter wavelength than visible .pdf
UV radiation has shorter wavelength than visible .pdf
 
(1) CA genetic model organism needs to have all the above features.pdf
(1) CA genetic model organism needs to have all the above features.pdf(1) CA genetic model organism needs to have all the above features.pdf
(1) CA genetic model organism needs to have all the above features.pdf
 
The relation in partSolution The relation in part.pdf
 The relation in partSolution The relation in part.pdf The relation in partSolution The relation in part.pdf
The relation in partSolution The relation in part.pdf
 
Step1 Concentration of hydroxide ion = 2x.00500=..pdf
                     Step1 Concentration of hydroxide ion = 2x.00500=..pdf                     Step1 Concentration of hydroxide ion = 2x.00500=..pdf
Step1 Concentration of hydroxide ion = 2x.00500=..pdf
 
molality = (11258.5)1 = 1.914 m Percent mass =.pdf
                     molality = (11258.5)1 = 1.914 m  Percent mass =.pdf                     molality = (11258.5)1 = 1.914 m  Percent mass =.pdf
molality = (11258.5)1 = 1.914 m Percent mass =.pdf
 
NADPH is a reducing agent that act as an electron.pdf
                     NADPH is a reducing agent that act as an electron.pdf                     NADPH is a reducing agent that act as an electron.pdf
NADPH is a reducing agent that act as an electron.pdf
 
moleculesions geometry hybridization ClF3 T-shap.pdf
                     moleculesions geometry hybridization ClF3 T-shap.pdf                     moleculesions geometry hybridization ClF3 T-shap.pdf
moleculesions geometry hybridization ClF3 T-shap.pdf
 
The major shortcoming was that the electrons were.pdf
                     The major shortcoming was that the electrons were.pdf                     The major shortcoming was that the electrons were.pdf
The major shortcoming was that the electrons were.pdf
 
The ball is an atom, the stick is a bond. You pu.pdf
                     The ball is an atom, the stick is a bond.  You pu.pdf                     The ball is an atom, the stick is a bond.  You pu.pdf
The ball is an atom, the stick is a bond. You pu.pdf
 
The anion is a good leaving group because it is p.pdf
                     The anion is a good leaving group because it is p.pdf                     The anion is a good leaving group because it is p.pdf
The anion is a good leaving group because it is p.pdf
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 

Último (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

CODEimport java.util.; public class test { public static voi.pdf

  • 1. CODE: import java.util.*; public class test { public static void main(String args[]) { int num, sum=0; Scanner input=new Scanner(System.in); System.out.print("Input num : "); num=input.nextInt(); while(num != 13) { sum=sum+num; System.out.print("Input num : "); num=input.nextInt(); } sum=sum+num; System.out.println("Sum = "+sum); } } save the above file as test.java Output: javac test.java java test Input num : 1 Input num : 2 Input num : 3 Input num : 4 Input num : 5
  • 2. Input num : 6 Input num : 7 Input num : 8 Input num : 9 Input num : 0 Input num : 13 Sum = 58 Solution CODE: import java.util.*; public class test { public static void main(String args[]) { int num, sum=0; Scanner input=new Scanner(System.in); System.out.print("Input num : "); num=input.nextInt(); while(num != 13) { sum=sum+num; System.out.print("Input num : "); num=input.nextInt(); }
  • 3. sum=sum+num; System.out.println("Sum = "+sum); } } save the above file as test.java Output: javac test.java java test Input num : 1 Input num : 2 Input num : 3 Input num : 4 Input num : 5 Input num : 6 Input num : 7 Input num : 8 Input num : 9 Input num :