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]
2 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]2 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
What makes the huns a formidable force for the roman empire?
Maurinko [17]
<span>The Huns were a formidable force to fight. They were able to eat most food without problem which removes the needs for supply trains and such and encourages pillaging. Another reason is that their a cavalry based army which completely decimated roman military since the roman empire consist of flat land and they could outflank, outrun, and could whittle down an army with ease. They also are nomads which means you don't know where they're living and so you can't be on the attack which also gave an advantage. This points that the Huns are a force to be reckon with.</span>
7 0
3 years ago
Word can store a maximum of how many documents in its Recent Documents area? five ten fifteen twenty
djyliett [7]
The answer is twenty.
5 0
2 years ago
A good machine should have the mechanical advantage of......?​
zavuch27 [327]

Answer:

The ideal mechanical advantage (IMA) of an inclined plane is the length of the incline divided by the vertical rise, the so-called run-to-rise ratio. The mechanical advantage increases as the slope of the incline decreases, but then the load will have to be moved a greater distance.

Explanation:

4 0
2 years ago
To ease giving access to network resources for employees, you decide there must be an easier way than granting users individual
scoundrel [369]

Answer

The intranet security model

Explanation:

This is an enterprise system that processes user information for security  and access authentication. It prevents unauthorized users, who are not part of the network resources from capturing these information.

The intranet security model is an efficient security procedure that incorporates web security  access control in keeping information safe over the intranet. It is also useful in encryption and decryption techniques.

4 0
2 years ago
Why is weather forecast so important for hang gliders?
professor190 [17]
Well, it wouldn't be such a good idea if they got caught up in a storm, would it? :p

Strong winds could blow them off-course, or even lightning has a chance of striking the hand glider, causing damage to the glider, the person, or even both.

Additionally, a weather forecast can help in my generic situations. For example, knowing whether to wrap up warm for cold weather, or wear something a bit more loose and breathable for hot weather.
6 0
3 years ago
Other questions:
  • Ian is working as a sales manager. He has to generate sales reports using mathematical data that his team has collected. Which c
    15·1 answer
  • You want to deploy software using group policy. what is necessary before deciding to assign the software to your user accounts?
    11·1 answer
  • A microphone, a track ball, and speakers are all examples of ____. hardware software
    6·2 answers
  • Potatocat2UwU da best
    12·1 answer
  • What is the analysis stage in System development life cycle?
    12·1 answer
  • The number of pixels that can be displayed on the screen at one time is known as what? screen resolution. viewing angle. color d
    5·1 answer
  • The linear programming ingredient or blending problem model allows one to include not only the cost of the resource, but also th
    14·1 answer
  • What is the standard unit used to measure mass?​
    9·1 answer
  • What is phishing?
    14·1 answer
  • Post back maintains view state by assigning the form values to a hidden form field named ____.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!