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
_________ is the start up sequence a computer conducts.
Travka [436]

Answer:

Booting

Explanation:

Booting is the start up sequence a computer conducts when it is being turned on. The booting is done by the operating system. The booting process is usually started when a hardware on the computer is pressed or by a software command. For a windows computer, the BIOS is used to start the booting sequence. These boot sequence is called boot order or BIOS boot sequence.

6 0
3 years ago
T<br> F<br> 5.<br> You can save presentations in PDF and XPS formats.
S_A_V [24]
True, presentations can be saved as PDF’s it will come out as separate pages though
7 0
3 years ago
For a new version of processor, suppose the capacitive load remains, how much more energy will the processor consume if we incre
erastovalidia [21]

Answer:

The answer is below

Explanation:

The amount of power dissipated by a processor is given by the formula:

P = fCV²

Where f = clock rate, C = capacitance and V = Voltage

For the old version of processor with a clock rate of f, capacitance C and voltage of V, the power dissipated is:

P(old) = fCV²

For the new version of processor with a clock rate of 20% increase = (100% + 20%)f = 1.2f, capacitance is the same = C and voltage of 20% increase = 1.2V, the power dissipated is:

P(new) = 1.2f × C × (1.2V)² = 1.2f × C × 1.44V² =1.728fCV² = 1.728 × Power dissipated by old processor

Hence, the new processor is 1.728 times (72.8% more) the power of the old processor

4 0
3 years ago
Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
Katarina [22]
The answer is C. Shareware
4 0
3 years ago
Read 2 more answers
________ is a command-line utility installed in the windows\system32 folder that displays information about your windows version
Ne4ueva [31]
Im pretty sure its SystemInfo...... 
6 0
3 years ago
Other questions:
  • Describe the Say It, Cover It, Resay It method.
    14·2 answers
  • Correspondence involves verbal communication. True False
    6·2 answers
  • What is the binding time for the following in C/C++ program. Explain. a. The location of memory of a local variable in a functio
    9·1 answer
  • What part of a check is the LEAST important?
    14·2 answers
  • Create the Following Menu in a loop so the menu will continually show until the user chooses to exit.AddMultiplyExitAdd a value
    10·1 answer
  • A binary message consisting of four bits was sent to you by a friend. The message was supposed to be ABAB. Unfortunately, your f
    8·1 answer
  • Assume you have an Access database with five different tables, including various pieces of information about your client base. Y
    9·1 answer
  • How dose society use computer in government?​
    5·1 answer
  • Reply emailing a student who is asking about audio materials​
    6·2 answers
  • The _____ layer addresses how the software will execute on specific computers and networks.
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!