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
6. What is saddle-stitch binding?
kifflom [539]
Commonly known as book stapling, ‘saddle stitched’ is one of the most popular binding methods. The technique uses printed sheets which are folded and nestled inside each other. These pages are then stapled together through the fold line. Saddle stitched binding can be applied to all book dimensions and both portrait and landscape orientation.
5 0
3 years ago
Read 2 more answers
For which tasks is Layout view most helpful? Check all that apply.
Solnce55 [7]

The task where the Layout view most helpful is showing how a report will look when printed.

<h3>What is the Layout view?</h3>

The Layout view is known to be a view that is said to be more of visually-oriented when compared to the Design view.

Note that the Layout view is one where each control often shows real data and as such, The task where the Layout view most helpful is showing how a report will look when printed.

Learn more about  Layout view  from

brainly.com/question/1327497

#SPJ1

6 0
2 years ago
Both IT professionals and governments must apply ethical principles to certify that emerging technologies are to society.
Katarina [22]
The answer is C fair………………………
6 0
2 years ago
If your body were a house, your skeleton would be the house's ___________.
frozen [14]
I think the answer is c wooden frame
3 0
3 years ago
Read 2 more answers
35 points please help!
Ahat [919]

Answer:

Microsoft Poweroint

Explanation:

this software helps people to present their projects.

7 0
4 years ago
Other questions:
  • What does this mean?
    7·2 answers
  • A particular BI analysis might require data from an ERP system, an e-commerce system, and a social networking application, but s
    5·1 answer
  • The default primary key for an access database is the id field true or falser
    7·1 answer
  • Nicole wants to create a database to collect information about videos in her video rental store. She would like to use the datab
    9·1 answer
  • In what year was the first mobile phone produced?
    15·1 answer
  • As more and more computing devices move into the home environment, there's a need for a centralized storage space, called a ____
    13·1 answer
  • Complete the below method, isPalindrome(), that takes in a String and returns a boolean. The boolean should be true if the Strin
    7·1 answer
  • Carlos is using the software development life cycle to create a new app. He has finished coding and is ready to see the output i
    12·2 answers
  • Type of cable installed on a patch panel?
    15·1 answer
  • _____ are labels for data, while _____ tie values together into one entity.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!