SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
Program:
import java.util.Scanner;
class Arithmetic // Here we are taking class name as Arithmetic
{
public static void main(String args[])
{
int x, y, a,b,c,e;
double d;
String s;
Scanner in = new Scanner(System.in); // here we are scanning input from key board
System.out.println("Please enter your name >>");
s = in.nextLine();
System.out.println("Please enter an integer >>");
x = in.nextInt();
System.out.println("Please enter another integer >>");
y = in.nextInt();
System.out.println("hey "+s+" here are your answers : ");
a = x + y;
System.out.println(x+" + "+y+" is "+a);
b= x - y;
System.out.println(x+" - "+y+" is "+b);
c = x * y;
System.out.println(x+" * "+y+" is "+c);
d = (double)x / (double)y; // Here we are converting integer value in to double
System.out.println(x+" / "+y+" is "+d);
e = x%y;
System.out.println(x+" % "+y+" is "+e);
}
}
Output :
Please enter your name >>
Budda
Please enter an integer >>
5
Please enter another integer >>
4
hey Budda here are your answers :
5 + 4 is 9
5 - 4 is 1
5 * 4 is 20
5 / 4 is 1.25
5 % 4 is 1
Solution
Program:
import java.util.Scanner;
class Arithmetic // Here we are taking class name as Arithmetic
{
public static void main(String args[])
{
int x, y, a,b,c,e;
double d;
String s;
Scanner in = new Scanner(System.in); // here we are scanning input from key board
System.out.println("Please enter your name >>");
s = in.nextLine();
System.out.println("Please enter an integer >>");
x = in.nextInt();
System.out.println("Please enter another integer >>");
y = in.nextInt();
System.out.println("hey "+s+" here are your answers : ");
a = x + y;
System.out.println(x+" + "+y+" is "+a);
b= x - y;
System.out.println(x+" - "+y+" is "+b);
c = x * y;
System.out.println(x+" * "+y+" is "+c);
d = (double)x / (double)y; // Here we are converting integer value in to double
System.out.println(x+" / "+y+" is "+d);
e = x%y;
System.out.println(x+" % "+y+" is "+e);
}
}
Output :
Please enter your name >>
Budda
Please enter an integer >>
5
Please enter another integer >>
4
hey Budda here are your answers :
5 + 4 is 9
5 - 4 is 1
5 * 4 is 20
5 / 4 is 1.25
5 % 4 is 1

Más contenido relacionado

Más de sharnapiyush773

“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf
sharnapiyush773
 
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdfThe Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
sharnapiyush773
 
The main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdfThe main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdf
sharnapiyush773
 
The expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdfThe expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdf
sharnapiyush773
 
public class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdfpublic class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdf
sharnapiyush773
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdf
sharnapiyush773
 
OSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdfOSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdf
sharnapiyush773
 
Note Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdfNote Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdf
sharnapiyush773
 
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdfOligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
sharnapiyush773
 
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdfMaroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
sharnapiyush773
 
In developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdfIn developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdf
sharnapiyush773
 
Bryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdfBryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdf
sharnapiyush773
 

Más de sharnapiyush773 (20)

“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf
 
Trueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdfTrueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdf
 
to upperSolutionto upper.pdf
to upperSolutionto upper.pdfto upperSolutionto upper.pdf
to upperSolutionto upper.pdf
 
there are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdfthere are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdf
 
The Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdfThe Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdf
 
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdfThe Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
 
The main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdfThe main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdf
 
The expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdfThe expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdf
 
public class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdfpublic class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdf
 
picture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdfpicture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdf
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdf
 
OSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdfOSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdf
 
Note Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdfNote Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdf
 
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdfOligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
 
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdfn = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
 
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdfMaroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
 
It lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdfIt lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdf
 
In developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdfIn developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdf
 
Bryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdfBryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdf
 
givenSolutiongiven.pdf
givenSolutiongiven.pdfgivenSolutiongiven.pdf
givenSolutiongiven.pdf
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Programimport java.util.Scanner; class Arithmetic Here we .pdf

  • 1. Program: import java.util.Scanner; class Arithmetic // Here we are taking class name as Arithmetic { public static void main(String args[]) { int x, y, a,b,c,e; double d; String s; Scanner in = new Scanner(System.in); // here we are scanning input from key board System.out.println("Please enter your name >>"); s = in.nextLine(); System.out.println("Please enter an integer >>"); x = in.nextInt(); System.out.println("Please enter another integer >>"); y = in.nextInt(); System.out.println("hey "+s+" here are your answers : "); a = x + y; System.out.println(x+" + "+y+" is "+a); b= x - y; System.out.println(x+" - "+y+" is "+b); c = x * y; System.out.println(x+" * "+y+" is "+c); d = (double)x / (double)y; // Here we are converting integer value in to double System.out.println(x+" / "+y+" is "+d); e = x%y; System.out.println(x+" % "+y+" is "+e); } } Output : Please enter your name >> Budda Please enter an integer >> 5
  • 2. Please enter another integer >> 4 hey Budda here are your answers : 5 + 4 is 9 5 - 4 is 1 5 * 4 is 20 5 / 4 is 1.25 5 % 4 is 1 Solution Program: import java.util.Scanner; class Arithmetic // Here we are taking class name as Arithmetic { public static void main(String args[]) { int x, y, a,b,c,e; double d; String s; Scanner in = new Scanner(System.in); // here we are scanning input from key board System.out.println("Please enter your name >>"); s = in.nextLine(); System.out.println("Please enter an integer >>"); x = in.nextInt(); System.out.println("Please enter another integer >>"); y = in.nextInt(); System.out.println("hey "+s+" here are your answers : "); a = x + y; System.out.println(x+" + "+y+" is "+a); b= x - y; System.out.println(x+" - "+y+" is "+b); c = x * y; System.out.println(x+" * "+y+" is "+c); d = (double)x / (double)y; // Here we are converting integer value in to double
  • 3. System.out.println(x+" / "+y+" is "+d); e = x%y; System.out.println(x+" % "+y+" is "+e); } } Output : Please enter your name >> Budda Please enter an integer >> 5 Please enter another integer >> 4 hey Budda here are your answers : 5 + 4 is 9 5 - 4 is 1 5 * 4 is 20 5 / 4 is 1.25 5 % 4 is 1