SlideShare a Scribd company logo
I have to write a java program . So basically I have to take my input in only cms. Inches is also
accepted but the inches should be converted into the cms before the program take in the input .
So when the program takes the input , the input must be in cm .
I have to write a java program . So basically I have to take my input in only cms. Inches is also
accepted but the inches should be converted into the cms before the program take in the input .
So when the program takes the input , the input must be in cm .
Solution
import java.io.*;
import java.util.*;
class InchesToCms{
public static void main (String[] args)throws Exception{
//1 Inches = 2.54 Centimeters;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));//to get
input creating bf is an object.
System.out.print("Enter the inches: ");//asking the input is inches
float inches = Float.parseFloat(bf.readLine());//geting input first in string,so convert into
float using parseFloat function.
float cms = inches * 2.54f;//multiplying given input inches and 2.54.
System.out.println(inches + " inches is " + cms + " centimeter(s).");//display the inches
and centimeters.
System.out.print("Enter the Centimeters: ");//asking the input is Centimeters.
float CMS = Float.parseFloat(bf.readLine());
System.out.println("You entered " +CMS+ " centimeter(s).");//display out put in
Centimeters only.
}
}
/* Output:
1) Enter the inches: 11.0
11.0 inches is 27.939999 centimeter(s).
Enter the Centimeters: 2.0
You entered 2.0 centimeter(s).
Explanatin:
This program 1) It takes input in inches and convert into centimeters
2) and Next It takes input in centimters and display the out in the same centimeters.
*/

More Related Content

Similar to I have to write a java program . So basically I have to take my in.pdf

import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
KUNALHARCHANDANI1
 
H U F F M A N Algorithm
H U F F M A N AlgorithmH U F F M A N Algorithm
H U F F M A N Algorithm
Jade Danial
 
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdfP1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
aquacareser
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
Deepak Singh
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
EPORI
 

Similar to I have to write a java program . So basically I have to take my in.pdf (20)

unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
C++basics
C++basicsC++basics
C++basics
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Cpp
CppCpp
Cpp
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in c
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
 
H U F F M A N Algorithm
H U F F M A N AlgorithmH U F F M A N Algorithm
H U F F M A N Algorithm
 
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdfP1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
 
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
ACM init()- Day 4
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
C++basics
C++basicsC++basics
C++basics
 
C++basics
C++basicsC++basics
C++basics
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 

More from FashionBoutiquedelhi

Questions1) How does multimedia transmission differ than messag.pdf
Questions1) How does multimedia transmission differ than messag.pdfQuestions1) How does multimedia transmission differ than messag.pdf
Questions1) How does multimedia transmission differ than messag.pdf
FashionBoutiquedelhi
 
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdfplease send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
FashionBoutiquedelhi
 
On January 1, 2002, Germany officially adopted the euro as its curre.pdf
On January 1, 2002, Germany officially adopted the euro as its curre.pdfOn January 1, 2002, Germany officially adopted the euro as its curre.pdf
On January 1, 2002, Germany officially adopted the euro as its curre.pdf
FashionBoutiquedelhi
 
Networking problem help Consider the following TCP session between h.pdf
Networking problem help Consider the following TCP session between h.pdfNetworking problem help Consider the following TCP session between h.pdf
Networking problem help Consider the following TCP session between h.pdf
FashionBoutiquedelhi
 
Just a general question on some vocab words I cannot piece together .pdf
Just a general question on some vocab words I cannot piece together .pdfJust a general question on some vocab words I cannot piece together .pdf
Just a general question on some vocab words I cannot piece together .pdf
FashionBoutiquedelhi
 
Explain how cellular respiration (O2 consumption and CO2 production).pdf
Explain how cellular respiration (O2 consumption and CO2 production).pdfExplain how cellular respiration (O2 consumption and CO2 production).pdf
Explain how cellular respiration (O2 consumption and CO2 production).pdf
FashionBoutiquedelhi
 
Can you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdfCan you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdf
FashionBoutiquedelhi
 

More from FashionBoutiquedelhi (20)

Questions1) How does multimedia transmission differ than messag.pdf
Questions1) How does multimedia transmission differ than messag.pdfQuestions1) How does multimedia transmission differ than messag.pdf
Questions1) How does multimedia transmission differ than messag.pdf
 
Question 1 of 10 Map sapling learning Based on the chart to the right.pdf
Question 1 of 10 Map sapling learning Based on the chart to the right.pdfQuestion 1 of 10 Map sapling learning Based on the chart to the right.pdf
Question 1 of 10 Map sapling learning Based on the chart to the right.pdf
 
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdfplease send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
please send edited code of RCBug.javaRCBUG.javaimport java.util..pdf
 
On January 1, 2002, Germany officially adopted the euro as its curre.pdf
On January 1, 2002, Germany officially adopted the euro as its curre.pdfOn January 1, 2002, Germany officially adopted the euro as its curre.pdf
On January 1, 2002, Germany officially adopted the euro as its curre.pdf
 
Networking problem help Consider the following TCP session between h.pdf
Networking problem help Consider the following TCP session between h.pdfNetworking problem help Consider the following TCP session between h.pdf
Networking problem help Consider the following TCP session between h.pdf
 
Lipid bilayers can only be synthesized by biological organisms. This .pdf
Lipid bilayers can only be synthesized by biological organisms. This .pdfLipid bilayers can only be synthesized by biological organisms. This .pdf
Lipid bilayers can only be synthesized by biological organisms. This .pdf
 
Is a neutral trait (meaning it is neither deleterious nor advantageo.pdf
Is a neutral trait (meaning it is neither deleterious nor advantageo.pdfIs a neutral trait (meaning it is neither deleterious nor advantageo.pdf
Is a neutral trait (meaning it is neither deleterious nor advantageo.pdf
 
Let T R^n rightarrow R^m be a linear transformation. Given a subspa.pdf
Let T  R^n rightarrow R^m be a linear transformation. Given a subspa.pdfLet T  R^n rightarrow R^m be a linear transformation. Given a subspa.pdf
Let T R^n rightarrow R^m be a linear transformation. Given a subspa.pdf
 
Just a general question on some vocab words I cannot piece together .pdf
Just a general question on some vocab words I cannot piece together .pdfJust a general question on some vocab words I cannot piece together .pdf
Just a general question on some vocab words I cannot piece together .pdf
 
In order to be useful to managers, management accounting reports shou.pdf
In order to be useful to managers, management accounting reports shou.pdfIn order to be useful to managers, management accounting reports shou.pdf
In order to be useful to managers, management accounting reports shou.pdf
 
Im also confused on question 9 and 10 On which point(s) would Charle.pdf
Im also confused on question 9 and 10 On which point(s) would Charle.pdfIm also confused on question 9 and 10 On which point(s) would Charle.pdf
Im also confused on question 9 and 10 On which point(s) would Charle.pdf
 
In about six billion years, our suns luminosity (a.k.a. power outpu.pdf
In about six billion years, our suns luminosity (a.k.a. power outpu.pdfIn about six billion years, our suns luminosity (a.k.a. power outpu.pdf
In about six billion years, our suns luminosity (a.k.a. power outpu.pdf
 
Fill in the blanks.Intensity of orangebrownred color of reduced .pdf
Fill in the blanks.Intensity of orangebrownred color of reduced .pdfFill in the blanks.Intensity of orangebrownred color of reduced .pdf
Fill in the blanks.Intensity of orangebrownred color of reduced .pdf
 
Explain how cellular respiration (O2 consumption and CO2 production).pdf
Explain how cellular respiration (O2 consumption and CO2 production).pdfExplain how cellular respiration (O2 consumption and CO2 production).pdf
Explain how cellular respiration (O2 consumption and CO2 production).pdf
 
Entrepreneurship isA. one of the basic rights of the private enter.pdf
Entrepreneurship isA. one of the basic rights of the private enter.pdfEntrepreneurship isA. one of the basic rights of the private enter.pdf
Entrepreneurship isA. one of the basic rights of the private enter.pdf
 
Discrete Random Variables we are working with commonly used discre.pdf
Discrete Random Variables we are working with commonly used discre.pdfDiscrete Random Variables we are working with commonly used discre.pdf
Discrete Random Variables we are working with commonly used discre.pdf
 
Determine the open intervals over which the function is increasing an.pdf
Determine the open intervals over which the function is increasing an.pdfDetermine the open intervals over which the function is increasing an.pdf
Determine the open intervals over which the function is increasing an.pdf
 
Discuss and define Isotropy. Anisotropy and Orthotropy with regards t.pdf
Discuss and define Isotropy. Anisotropy and Orthotropy with regards t.pdfDiscuss and define Isotropy. Anisotropy and Orthotropy with regards t.pdf
Discuss and define Isotropy. Anisotropy and Orthotropy with regards t.pdf
 
Consider the circuits in figure 2.32. If we assume the transistors ar.pdf
Consider the circuits in figure 2.32. If we assume the transistors ar.pdfConsider the circuits in figure 2.32. If we assume the transistors ar.pdf
Consider the circuits in figure 2.32. If we assume the transistors ar.pdf
 
Can you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdfCan you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdf
 

Recently uploaded

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 

I have to write a java program . So basically I have to take my in.pdf

  • 1. I have to write a java program . So basically I have to take my input in only cms. Inches is also accepted but the inches should be converted into the cms before the program take in the input . So when the program takes the input , the input must be in cm . I have to write a java program . So basically I have to take my input in only cms. Inches is also accepted but the inches should be converted into the cms before the program take in the input . So when the program takes the input , the input must be in cm . Solution import java.io.*; import java.util.*; class InchesToCms{ public static void main (String[] args)throws Exception{ //1 Inches = 2.54 Centimeters; BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));//to get input creating bf is an object. System.out.print("Enter the inches: ");//asking the input is inches float inches = Float.parseFloat(bf.readLine());//geting input first in string,so convert into float using parseFloat function. float cms = inches * 2.54f;//multiplying given input inches and 2.54. System.out.println(inches + " inches is " + cms + " centimeter(s).");//display the inches and centimeters. System.out.print("Enter the Centimeters: ");//asking the input is Centimeters. float CMS = Float.parseFloat(bf.readLine()); System.out.println("You entered " +CMS+ " centimeter(s).");//display out put in Centimeters only. } } /* Output: 1) Enter the inches: 11.0 11.0 inches is 27.939999 centimeter(s).
  • 2. Enter the Centimeters: 2.0 You entered 2.0 centimeter(s). Explanatin: This program 1) It takes input in inches and convert into centimeters 2) and Next It takes input in centimters and display the out in the same centimeters. */