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
Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
Mama L [17]

Answer:

def shampoo_instructions(num_cycles):

   #Check the cycles to be greater than 1.

   if num_cycles < 1:

     

       #Display the statement.

       print('Too few.')

     

   #Check the cycles to be greater than 4.

   elif num_cycles > 4:

     

       #Display the statement.

       print('Too many.')

     

   #The else part.

   else:

     

       #Initialize the variable.

       N = 1;

         

       #Begin the for loop.

       for N in range(N, num_cycles+1):

         

           #Print the result.

           print(N , ": Lather and rinse.")

         

       #Print the statement.

       print('Done.')

#Call the function.

shampoo_instructions(2)

Explanation:

7 0
3 years ago
When coding, how do you get animations to work??
Nina [5.8K]

Answer:

Blender's animation & rigging if you are talking about 3d modeling.

Explanation:

Blender is a standard free to use universally used software used in animation for most standard games. You learn to model, then to rig with bones, then to animate. Animations don't entirely go with coding unless you are calling them in the code to make them play.

7 0
4 years ago
The atmosphere can produce the same effects as a
IceJOKER [234]
The answer is prism, The atmosphere can produce the same effects<span> as a </span>prism<span> when the </span>Sun is low in the sky<span>.  </span>
3 0
3 years ago
Which of the following are some popular debugging techniques?
topjm [15]

Answer:

a fix any syntax bugs. I looked it up on the internet so you should be good good luck on your test

8 0
3 years ago
A network interface port has collision detection and carrier sensing enabled on a shared twisted-pair network. From this stateme
hram777 [196]

Answer:

This is an Ethernet port operating at half duplex.

Explanation:

Modern Ethernet networks built with switches and full-duplex connections no longer utilize CSMA/CD. CSMA/CD is only used in obsolete shared media Ethernet (which uses repeater or hub).

7 0
3 years ago
Read 2 more answers
Other questions:
  • it is important to include the __ attribute of the tag because some people use text-only web browsers
    5·2 answers
  • Once your hard drive is installed what needs to be done to the drive and what do these two tasks do
    12·1 answer
  • Which education level has the highest return on investment (ROI)?
    14·1 answer
  • How could you insert a new row between rows 20 and 21?
    10·2 answers
  • Do you think an employer can accurately judge an applicant’s skills and character by reviewing his/her job application? Why or w
    14·1 answer
  • (40 pointsAnd brainliest answer ASAP) Maria is recording her friend’s graduation ceremony. How can Maria ensure that the video i
    15·1 answer
  • QUESTION 16
    14·1 answer
  • This is a type race kindly join.
    11·1 answer
  • Create the HTML code for this
    14·1 answer
  • Your primary responsibility as a systems analyst concerns:_____.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!