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
Ushahidi is a crisis-mapping tool that makes information instantly available to anyone in the world. T/F
andrezito [222]

Answer: True

Explanation: Ushahidi is technology that is responsible for the dividing the work and gaining the outcomes from the public accounting ,publishing, social activities for the instantly making the information available towards the world.

It is a non-profit organization that is responsible for the distribution of any products to clients for the crisis mapping mechanism and gaining the feedback reports.

4 0
3 years ago
The most likely reason that company computers connected to the Internet should use anti-virus protection software is..?
gogolik [260]
A big/potent virus could eliminate economic statuses/money, maybe bankrupting the company. 
4 0
3 years ago
You are running your warehouse using Autonomous Data Warehouse (ADW) service and you noticed that a newly configured batch job i
Phantasy [73]

Answer:

<u>C. The new batch job is connected to the LOW consumer group.</u>

Explanation:

<em>Remember</em>, one of the main characteristics of the LOW consumer group <u>database service</u> is that queries would run serially.

Since in this case, we are told that the newly configured batch job is always running in serial, it most likely would be because the new batch job is connected to the LOW consumer group; as queries are designed to always run serially.

6 0
3 years ago
Which business case is better solved by Artificial intelligence than conventional programming?<br>​
skad [1K]

Answer:

Predicting characteristics of high-value customers is the business case that better solved by Artificial intelligence than conventional programming.

Explanation:

Many corporations and businesses predict CLVs only by resembling at the total monetary expense of sales, without recognition circumstances. For instance, a customer who executes one big order might be less worthwhile than another consumer who purchases multiple occasions, but in more diminutive amounts.

4 0
3 years ago
Within an event-driven program a component from which an event is generated is the ____
mojhsa [17]
The answer is: <span>Source of the Event</span>
7 0
3 years ago
Other questions:
  • What was the first browser that allowed for graphics to be viewed on the web?
    14·2 answers
  • Network signaling is a function of which layer of the osi model
    10·1 answer
  • What is software that, while purporting to serve some useful function and often fulfilling that function, also allows Internet a
    11·1 answer
  • printLarger is a method that accepts two int arguments and returns no value. Two int variables, sales1 and sales2, have already
    11·1 answer
  • Ancestor(X,father(X)) and ancestor(david,george) is they unify or not
    11·1 answer
  • Assuming the Direct Hashing function and the Subtraction preprocessing algorithm is used to map keys into indices, give the inde
    15·1 answer
  • Excel spread sheets are primarily used to
    13·2 answers
  • You can get context-sensitive help information from the Code Editor by_________.A) selecting Contents from the Help menu
    9·1 answer
  • Define Agricultural Era
    14·2 answers
  • If String str = "Computer Science";, then what is the value of str.substring(10);? ​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!