SlideShare a Scribd company logo
1 of 2
Download to read offline
// Accepts number and base and returns result in integer
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Base {
public static void main(String[] args) throws IOException {
System.out.println("Enter number: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String st=br.readLine();
System.out.println("Enter base");
String st1=br.readLine();
int n=Integer.parseInt(st);
int b=Integer.parseInt(st1);
int sum=0;
int i=0;
while(n!=0)
{
sum=(int) (sum+(n%10)*Math.pow(b,i++));
n=n/10;
}
System.out.println(sum);
}
}
Solution
// Accepts number and base and returns result in integer
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Base {
public static void main(String[] args) throws IOException {
System.out.println("Enter number: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String st=br.readLine();
System.out.println("Enter base");
String st1=br.readLine();
int n=Integer.parseInt(st);
int b=Integer.parseInt(st1);
int sum=0;
int i=0;
while(n!=0)
{
sum=(int) (sum+(n%10)*Math.pow(b,i++));
n=n/10;
}
System.out.println(sum);
}
}

More Related Content

Similar to Accepts number and base and returns result in integerimport jav.pdf

Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfmanojmozy
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfpratyushraj61
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdfICADCMLTPC
 
Below is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdfBelow is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdfalankarshoe84
 
this is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxthis is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxabhi353063
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
 

Similar to Accepts number and base and returns result in integerimport jav.pdf (20)

Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
 
Why Learn Python?
Why Learn Python?Why Learn Python?
Why Learn Python?
 
Lab4
Lab4Lab4
Lab4
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
C#.net
C#.netC#.net
C#.net
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
Below is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdfBelow is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdf
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
this is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxthis is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docx
 
CORE JAVA-1
CORE JAVA-1CORE JAVA-1
CORE JAVA-1
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
Java Program
Java ProgramJava Program
Java Program
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 

More from asif1401

the reaction of A to B since its Ea is the highes.pdf
                     the reaction of A to B since its Ea is the highes.pdf                     the reaction of A to B since its Ea is the highes.pdf
the reaction of A to B since its Ea is the highes.pdfasif1401
 
the one thing that comes to mind for me is about .pdf
                     the one thing that comes to mind for me is about .pdf                     the one thing that comes to mind for me is about .pdf
the one thing that comes to mind for me is about .pdfasif1401
 
#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdfasif1401
 
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdfasif1401
 
Iodine will replace both Cl and Br It will be SN2.pdf
                     Iodine will replace both Cl and Br It will be SN2.pdf                     Iodine will replace both Cl and Br It will be SN2.pdf
Iodine will replace both Cl and Br It will be SN2.pdfasif1401
 
The number of outcomes in the event A is 4 Yes event A is a s.pdf
 The number of outcomes in the event A is 4 Yes event A is a s.pdf The number of outcomes in the event A is 4 Yes event A is a s.pdf
The number of outcomes in the event A is 4 Yes event A is a s.pdfasif1401
 
There were very few planetary leftovers in this r.pdf
                     There were very few planetary leftovers in this r.pdf                     There were very few planetary leftovers in this r.pdf
There were very few planetary leftovers in this r.pdfasif1401
 
i have no idea. im just seeing if i get karma p.pdf
                     i have no idea. im just seeing if i get karma p.pdf                     i have no idea. im just seeing if i get karma p.pdf
i have no idea. im just seeing if i get karma p.pdfasif1401
 
Fe+3 solution is more acidic because it produces .pdf
                     Fe+3 solution is more acidic because it produces .pdf                     Fe+3 solution is more acidic because it produces .pdf
Fe+3 solution is more acidic because it produces .pdfasif1401
 
Copper chloride. Copper ions will form precipitat.pdf
                     Copper chloride. Copper ions will form precipitat.pdf                     Copper chloride. Copper ions will form precipitat.pdf
Copper chloride. Copper ions will form precipitat.pdfasif1401
 
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdfasif1401
 
User interface design processNavigation DesignInput DesignOu.pdf
User interface design processNavigation DesignInput DesignOu.pdfUser interface design processNavigation DesignInput DesignOu.pdf
User interface design processNavigation DesignInput DesignOu.pdfasif1401
 
True.it  is an example of an independent-measures designSolution.pdf
True.it  is an example of an independent-measures designSolution.pdfTrue.it  is an example of an independent-measures designSolution.pdf
True.it  is an example of an independent-measures designSolution.pdfasif1401
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfasif1401
 
the inner electronsSolutionthe inner electrons.pdf
the inner electronsSolutionthe inner electrons.pdfthe inner electronsSolutionthe inner electrons.pdf
the inner electronsSolutionthe inner electrons.pdfasif1401
 
SolutionThe investees net income should be recorded as an increa.pdf
SolutionThe investees net income should be recorded as an increa.pdfSolutionThe investees net income should be recorded as an increa.pdf
SolutionThe investees net income should be recorded as an increa.pdfasif1401
 
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdf
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdfQuestionAnswer1TrueThe corpus callosum , otherwise called th.pdf
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdfasif1401
 
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdf
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdfNo. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdf
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdfasif1401
 
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdf
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdfLet the sample size be n ,Mean of the sample = 27 (same as pop.pdf
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdfasif1401
 
JeffSolutionJeff.pdf
JeffSolutionJeff.pdfJeffSolutionJeff.pdf
JeffSolutionJeff.pdfasif1401
 

More from asif1401 (20)

the reaction of A to B since its Ea is the highes.pdf
                     the reaction of A to B since its Ea is the highes.pdf                     the reaction of A to B since its Ea is the highes.pdf
the reaction of A to B since its Ea is the highes.pdf
 
the one thing that comes to mind for me is about .pdf
                     the one thing that comes to mind for me is about .pdf                     the one thing that comes to mind for me is about .pdf
the one thing that comes to mind for me is about .pdf
 
#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf
 
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf
(1) Acid rain occurs when the gases SO2 ,NOx react with water,oxygen.pdf
 
Iodine will replace both Cl and Br It will be SN2.pdf
                     Iodine will replace both Cl and Br It will be SN2.pdf                     Iodine will replace both Cl and Br It will be SN2.pdf
Iodine will replace both Cl and Br It will be SN2.pdf
 
The number of outcomes in the event A is 4 Yes event A is a s.pdf
 The number of outcomes in the event A is 4 Yes event A is a s.pdf The number of outcomes in the event A is 4 Yes event A is a s.pdf
The number of outcomes in the event A is 4 Yes event A is a s.pdf
 
There were very few planetary leftovers in this r.pdf
                     There were very few planetary leftovers in this r.pdf                     There were very few planetary leftovers in this r.pdf
There were very few planetary leftovers in this r.pdf
 
i have no idea. im just seeing if i get karma p.pdf
                     i have no idea. im just seeing if i get karma p.pdf                     i have no idea. im just seeing if i get karma p.pdf
i have no idea. im just seeing if i get karma p.pdf
 
Fe+3 solution is more acidic because it produces .pdf
                     Fe+3 solution is more acidic because it produces .pdf                     Fe+3 solution is more acidic because it produces .pdf
Fe+3 solution is more acidic because it produces .pdf
 
Copper chloride. Copper ions will form precipitat.pdf
                     Copper chloride. Copper ions will form precipitat.pdf                     Copper chloride. Copper ions will form precipitat.pdf
Copper chloride. Copper ions will form precipitat.pdf
 
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf
   CCl4 molecule can give IR and Raman spectroscopy.   Selection r.pdf
 
User interface design processNavigation DesignInput DesignOu.pdf
User interface design processNavigation DesignInput DesignOu.pdfUser interface design processNavigation DesignInput DesignOu.pdf
User interface design processNavigation DesignInput DesignOu.pdf
 
True.it  is an example of an independent-measures designSolution.pdf
True.it  is an example of an independent-measures designSolution.pdfTrue.it  is an example of an independent-measures designSolution.pdf
True.it  is an example of an independent-measures designSolution.pdf
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
the inner electronsSolutionthe inner electrons.pdf
the inner electronsSolutionthe inner electrons.pdfthe inner electronsSolutionthe inner electrons.pdf
the inner electronsSolutionthe inner electrons.pdf
 
SolutionThe investees net income should be recorded as an increa.pdf
SolutionThe investees net income should be recorded as an increa.pdfSolutionThe investees net income should be recorded as an increa.pdf
SolutionThe investees net income should be recorded as an increa.pdf
 
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdf
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdfQuestionAnswer1TrueThe corpus callosum , otherwise called th.pdf
QuestionAnswer1TrueThe corpus callosum , otherwise called th.pdf
 
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdf
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdfNo. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdf
No. of Moles = Given MassMolecular Mass=3.0 x 101398= 3.06101.pdf
 
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdf
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdfLet the sample size be n ,Mean of the sample = 27 (same as pop.pdf
Let the sample size be n ,Mean of the sample = 27 (same as pop.pdf
 
JeffSolutionJeff.pdf
JeffSolutionJeff.pdfJeffSolutionJeff.pdf
JeffSolutionJeff.pdf
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

Accepts number and base and returns result in integerimport jav.pdf

  • 1. // Accepts number and base and returns result in integer import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Base { public static void main(String[] args) throws IOException { System.out.println("Enter number: "); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String st=br.readLine(); System.out.println("Enter base"); String st1=br.readLine(); int n=Integer.parseInt(st); int b=Integer.parseInt(st1); int sum=0; int i=0; while(n!=0) { sum=(int) (sum+(n%10)*Math.pow(b,i++)); n=n/10; } System.out.println(sum); } } Solution // Accepts number and base and returns result in integer import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Base { public static void main(String[] args) throws IOException {
  • 2. System.out.println("Enter number: "); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String st=br.readLine(); System.out.println("Enter base"); String st1=br.readLine(); int n=Integer.parseInt(st); int b=Integer.parseInt(st1); int sum=0; int i=0; while(n!=0) { sum=(int) (sum+(n%10)*Math.pow(b,i++)); n=n/10; } System.out.println(sum); } }