1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
guapka [62]
3 years ago
13

Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to conv

ert (a String) Accept that String Prompt the user for the value of the initial base (an integer) Accept that integer Prompt the user for the desired base of the output (an integer) Accept that integer If the String is not a legal expression of a number in the initial base, display an error message and exit the program. Convert the value represented by the String in the initial base to the desired base. Display the result.
Computers and Technology
1 answer:
andrezito [222]3 years ago
3 0

Explanation:

import java.util.Scanner;

import java.math.BigInteger;

public class Main

{

private int x;  

public static boolean isValidInteger(String theValue, int theBase)

{    

BigInteger number = new BigInteger(theValue,theBase);

if(theValue.equals(number.toString(theBase)))

{

return true;

}

else

return false;

}

public static String convertInteger(String theValue, int initialBase, int finalBase)

{

boolean valid=isValidInteger(theValue,initialBase);

if(valid==true)

{

BigInteger number = new BigInteger(theValue);

return(number.toString(finalBase));

}

else

return("String not in initial base");  

}

public static void main(String[] args)

{

System.out.println("Welcome");

String value;

int ibase, dbase;

if(args.length==0)

{

Scanner S = new Scanner(System.in);

System.out.println("Enter Value to be converted :: ");

value = S.nextLine();

System.out.println("Enter initial base :: ");

ibase = S.nextInt();

System.out.println("Enter desired base :: ");

dbase = S.nextInt();

}

else

{

value=args[0];

ibase=Integer.parseInt(args[1]);

dbase=Integer.parseInt(args[2]);

}

  System.out.println("Change base "+convertInteger(value,ibase,dbase));  

}

}

Output

You might be interested in
To navigate to a new web page for which you know the url, type that url in the browser’s ____ bar and press enter.
Slav-nsk [51]
It would be to type the url in the browser's address bar
3 0
3 years ago
WHAT DO YOU KNOW?<br> Why would you want to change your Table<br> Properties?
joja [24]

read the slides ;  Table Properties are the way the table appears or looks.

6 0
2 years ago
When evaluating a website's content, whether or not the information is up to date is considered part of the ________ element.
nirvana33 [79]

The currency element constitutes information whether the information of the website is current or up to date.

<h3>Website</h3>

A website is a term used to describe unique publicly accessible web pages that are identified by a domain name. Information on websites is typically updated by website owners, hence, some websites may not be updated frequently when compared to others. Thus, the currency element is an element users take into consideration when evaluating a website's content, whether or not the information is up to date.

You can learn more about the currency element here https://brainly.in/question/48673521

#SPJ1

3 0
2 years ago
The P in SOAP stands for Persuasion. <br> a. True<br> b. False
fredd [130]
The answer is false.
  P in soap stands for purpose. SOAPS stands for Subject(what is being discussed), Occasion(what is the context of events), Audience(to whom the message is directed), Purpose(what is the recommended action for the reader) and the Speaker(what or who is the source).
4 0
3 years ago
Read 2 more answers
If you insert a picture, resize and reposition it, and then change to a different picture, you must modify the new picture to
Mashcka [7]

Answer:

false , that is not true

Explanation:

because a person can change to a different picture , but it Is not by force it will have a match to the original

3 0
2 years ago
Read 2 more answers
Other questions:
  • Which is the most important reason you should properly cite information that you obtain from an Internet search? Question 2 opti
    8·1 answer
  • How do you find the exterior angle measure of any regular polygon? (The degree in which to turn the turtle to draw a shape)
    10·1 answer
  • What is the difference between omr and ocr?
    11·1 answer
  • Select the correct answer
    11·2 answers
  • An interrupt priority scheme can be used to ____. allow the most urgent work to be finished first make it possible for high-prio
    14·1 answer
  • Private sharing model on Opportunities. Leadership has asked the Administrator to create a new custom object that will track cus
    7·1 answer
  • Specialized high-capacity second storage devices designed to meet organizational demands
    12·2 answers
  • The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi
    13·1 answer
  • What makes you normally visit the site-graphics, layout, or content? Why?​
    8·2 answers
  • 3 ways that can be used to connect computers to a network
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!