Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to convert (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.

Answers

Answer 1

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


Related Questions

Write a Java program that prompts the user for an int n. You can assume that 1 ≤ n ≤ 9. Your program should use embedded for loops that produce the following output: 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 . . . n . . . 5 4 3 2 1 Your prompt to the user should be: Please enter a number 1...9 : Please note that your class should be named PatternTwo.

Answers

Answer:

Here is the JAVA program:

import java.util.Scanner;  // to take input from user

public class PatternTwo{   //class name

public static void main(String args[]){  //start of main function

Scanner scan = new Scanner(System.in);   // creates Scanner class object

System.out.print("Please enter a number: ");  //prompts user to enter an int n for the number of rows

int n = scan.nextInt();   //reads and scans the value of n from user

int i, j;   //declares two variables to iterate through i  rows and j columns

for (i=1; i<=n; i++){    //outer loop for rows  

for (j=2*(n-i); j>=1; j--){   //inner loop for space between numbers in pattern  

System.out.print(" ");  }   //displays an empty space in the pattern

for (j = i; j >= 1; j--)  { //inner loop for columns  

System.out.print(j+" "); }   //prints the value of j (prints numbers in reverse)

System.out.println();   }   }   }  //prints a new line after printing each row

Explanation:

The program is explained with an example in the attached document.

When following maintenance procedures, it is important to carefully read the procedures and to complete
each step before moving to the next step.
True or
False

Answers

True, is the way to go

Help meeeee - Improved Pet App


Try out the improved version of the pet app that gives the user information about pet stores close by, which uses new sources of input. Determine the information that the app gets from each source of input.


User


Phone Sensors


Internet








Answers

Answer:

Did you do it? Can you give me the answers please‍♀️

Explanation:

Pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeee

What are language standards? At this point in your study of programming, what do they mean to
you?

Answers

In computing, a programming language specification (or standard or definition) is a documentation artifact that defines a programming language so that users and implementors can agree on what programs in that language mean.

The binary string 00100100 is a member of which of the following problems? Remember, a "problem" is a language whose strings represent the cases of a problem that have the answer "yes." In this question, you should assume that all languages are sets of binary strings interpreted as base-2 integers. The exception is the problem of finding palindromes, which are strings that are identical when reversed, like 00100100, regardless of their numerical value.

Answers

This question is incomplete, the complete question is;

The binary string 00100100 is a member of which of the following problems? Remember, a "problem" is a language whose strings represent the cases of a problem that have the answer "yes." In this question, you should assume that all languages are sets of binary strings interpreted as base-2 integers. The exception is the problem of finding palindromes, which are strings that are identical when reversed, like 00100100, regardless of their numerical value.

a) Is the given string a palindromes ?

b) Is the given string a perfect cube?

c) Is the given string greater than 50?

d) Is the given string even?

e) is the given string a perfect square?

Answer:

a) the given binary string is a palindromes

b) the given string is NOT a perfect cube

c) the given string is NOT greater than 50?

d) the given string is an even

e) the given string a perfect square

Explanation:

Given that;

binary string : 00100100

a)

Is the given string a palindromes ?

the given binary string = 00100100

now when you reverse the string, its still going to be : 00100100

so the given binary string is a palindromes

b)

Is the given string a perfect cube

the given string : 00100100 = 36

now 2^3 = 8,

3^3 = 27,

4^3 = 64

so 36 is not a perfect cubic

hence the given string is NOT a perfect cube

c)

Is the given string greater than 50?

the given string : 00100100 = 36

and 36 < 50

so the given string is NOT greater than 50?

d)

Is the given string even?

the given string  : 00100100 = 36

and 36 can be divided exactly by 2

so the given string is an even

e)

is the given string a perfect square?

the given string  : 00100100 = 36

now 6^2 = 36  i.e 6 multiply by 6 = 36

therefore the given string a perfect square

In an inspection, usually the first thing an inspector will want to see is:

Answers

Answer:

Your records and paperwork

Your paperwork, your skills, and your background/ record.

Assignment 1 silly sentences

Answers

Answer:

Sally sells sea shells by the sea shore

Explanation:

why is makyra a loser??​

Answers

Because she doesn’t have any friends :-(

Answer:

She dumbbbbbbbbbbbbbbbbbbbbbb

Explanation: Her mom watched too much spongebob while pregnant

Sorry if this is not related.


What is the best game programming language to learn?

Answers

These are my recommendations but you should just try to find the one that’s right for you ——
Python for beginners.
C++ for game development. (C# for unity game development )
html5 for web development.
Java or JavaScript for software development
I suggest you to try either Visual Studio, Python or Java and JavaScript.
Python and Java are comparingly easy.

How do you begin typing in a table cell?

A. Click within a cell and begin typing.

B. Highlight the table and begin typing.

C. Click on the Convert to Text button in the Layout ribbon.

D. Right-click and select Text Direction.

Answers

Its Option A - Click Within a Cell and begin typing.
Thank you!

To begin typing in a table cell, click within a cell and begin typing. The correct option is A.

What is a table cell?

A table cell is a subset of a chart table that is used to store information or data. Cells are organized both horizontally and vertically.

Each cell contains information about the combination of row and column headings with which it is collinear.

Text, numbers, and a variety of other elements can be included in table cells. Tables were originally used only to display numbers, but they are now useful for a wide variety of tasks.

To begin typing text into a cell, simply select a cell and start typing. To select text that is already inside a cell, place the insertion point within the cell.

In either mode, you can use the arrow keys to navigate around the table, making it simple to enter text into any cell.

Thus, the correct option is A.

For more details regarding a table cell, visit:

https://brainly.com/question/8059827

#SPJ5

What are three things to consider in programming design?
the problem being addressed, the goals of the project, and the programming language that will be used
the problem being addressed, the goals of the project, and the age of the end users
the age of the end users, the programming language that will be used, and the programming style of the
programmers working on the project
the age of the end users, the goals of the project, and the programming style of the programmers working on the
project

Answers

The issue being solved, the project's objectives, and the users' ages. The project's programmers' programming styles, the programming language they will use, and the age of the intended customers.

What is programming language?

Programming language is defined as a computer language used to converse with computers by programmers (developers). Orthogonality or simplicity, available control structures, data types, and data structures, syntactic design, support for abstraction, expressiveness, type equivalence, strong versus weak type checking, exception handling, and limited aliasing are among the characteristics of a programming language.

Clarity, simplicity, and unity offer a way to express algorithms as well as a framework for thinking about them. Every possible feature combination has value thanks to orthogonality. Surprisingly, it may frequently be reduced to three basic programming constructs known as loops, selects, and sequences.

Thus, the issue being solved, the project's objectives, and the users' ages. The project's programmers' programming styles, the programming language they will use, and the age of the intended customers.

To learn more about programming language, refer to the link below:

https://brainly.com/question/12696037

#SPJ5

what is the color of red?

Answers

Answer:

red

Explanation:

orange and red

Answer: Red

Explanation: The reason why it's red is because of how we see colors through our eyes.

What problems might you encounter when using the Web for research?
a. Lack of current news
b. Undocumented sources
c. Lack of search tools
d. Time-consuming searches
e. Unreliable conten

Answers

Answer:

b. d. e.

Explanation:

The web is a vast and endless database of information and has become an invaluable resource for research. That being said it can also bring with it many problems, the main one being unreliable content due to undocumented sources, false testimonies, information with no evidence, etc. The amount of false information on the internet can sometimes make it very time consuming since you have to take the extra step of verifying the information you come across. Despite this, the WEB has information on every topic including current news, and with the wide array of search tools available it is very easy to find what you are looking for.

Many of the first photographers were actullay scientists and inventors

Answers

Answer:

True, if its a true or false. Otherwise I am of no help.

Explanation:

Answer:

True

Explanation:

what are the earliest invention in human history​

Answers

Answer: Tools, Boats, Hand made bricks.

Explanation: The tools were the first technological advancement, the boats were the next, them hand made bricks for construction.

1605:newspapers
1608:telescope
1620:Compound microscope
1630:Slide rule
1642:mechanical calculator 1643:barometer
1650:vacuum pump
1656:pendulum clock

Hope this is enough

10010010 + 01100010 =

The problem above is called an _________. It means that there are more ________ than can be stored in a byte, or eight bit number.

Answers

Answer:

1. binary number or 8 bit

2. bits

Explanation:

Why is it unlawful for an employer to refuse to employ someone based solely on their gender without evidence that such a characteristic is necessary for successful completion of the job? Answer by writing a paragraph of two to three sentences.

Answers

Employing someone based on gender is unlawful because, it is the skill which matters to get the required job done and skills are not based on gender. There is no evidence that this particular gender cannot do this job and this particular gender can do. Everyone who posses the required skillsets are eligible to get employed irrespective of gender.

===============================================

I tried my best

Choose all of the items that represent functions of the operating system kernel.

memory management

process management

user interface

system input and output (I/O) management

file creation and management

Answers

Answer:

A. memory management

B. process management

D. system input and output (I/O) management

E. file creation and management

Answer:

1,2,4,5

Explanation:

E2020 - Intro to Information Technology

What is 10X Profit Sites?

Answers

Answer:

Wow! That's amazing!

Explanation:

People convicted of cyberbullying in most states
face no punishment for their actions.
face varying degrees of punishment.
are taught how to use technology positively.
are forced to do community service.

Answers

Answer: The Answer is B. face varying degrees of punishment.

Hope this helps! ^^ (also i know this is the right answer because i got it correct)

Answer:

b

Explanation: the punishment depends on the severeness , so we dont know the exact punishment

Match each task with the features necessary to complete the task

Answers

Is there supposed to be an image?

Naseer has inserted an image into his document but needs the image to appear on its own line.

Which option should he choose?

•Top and Bottom
•Tight
•Through
•In front of text

Answers

Answer:

Top and Bottom

Explanation:

took the test

Answer: A

Explanation:

What is the difference between an IP address and an IP Packet?

Answers

Answer:

The IP address is a numerical number assigned to a device when connected to the internet for better identification. Whereas, the IP packet is the packet which contains the total information of the content that is carried over the network from host to destination and vice versa.

Explanation:

I hope this helped and plz give brainliest!

briefly explain the usage of the MS PowerPoint

Answers

Answer:

PowerPoint is a computer program that allows you to create and show slides to support a presentation. You can combine text, graphics and multi-media content to create professional presentations.

Answer:

Making your presentation more interesting through the use of multimedia can help to improve the audience's focus. PowerPoint allows you to use images, audio and video to have a greater visual impact. These visual and audio cues may also help a presenter be more improvisational and interactive with the audience.

Help me for this question

Answers

Answer:

Answer C

Explanation:

You are welcome

which of the following is involved in ordering an outline. A.grouping B.merging C.organizing D.arranging

Answers

Answer:

The answer is A.GROUPING

HOPE THIS HELPS...

Answer:

nice name

Explanation:

true false) keybord has two shift keys.​

Answers

Answer:

True, looking at 'em right now!

Explanation:

Explain why decomposition will be used in creating the algorithm for the game including two dice.

Answers

I saw this question while reviewing the notes in class

which check the functioning of all the connected hardwares including primary and secondary storage devices​

Answers

Answer: The computer processor

Explanation:

The computer processor is also called the central processing unit and it's function is to analyzes data and also disperses data. It is the computer's brain as it tells the computer the kind of programs to do at a particular time.

The computer processor checks the functioning of all the connected hardwares including primary and secondary storage devices.

Which color reflects more light red blue black or white

Answers

White black absorbs the light
Other Questions
I need help! With this problem for what value of x does f(x)= -2 A DESPRITE CRY FOR HELP!!!! WILL MARK BRAINLIESTWhat are the products of photosynthesis?carbon dioxide and hydrogenhydrogen, oxygen, and waterlight energy, water, and carbon dioxideoxygen and glucose can someone tell me if this is a good hook or just stupid "It is no secret that video games are transforming our lives, a study proves that video games are known to help kids with ADHD and dyslexia." I feel like ""It is no secret" is kinda dumb and i should leave it out. thoughtss? The density of silver is 10.5 g/cm3. What is the mass (in kilograms) of a cube of silver that measures 0.94 m on each side? Write an equation/inequality to represent the description. * Baking powder is example of??? Can yall help please? 21 kg of apples cost $210. How many kilograms of apples can you get with $270 ? please answer asap Are flowers naturally rainbow colored? Please describe how the store canhave a rainbow colored plant (using the terms xylem or phloem.) A 35-foot ladder is leaning against the side of a building and is positioned such that the base of the ladder is 21 feet from the base of the building. How far above the ground is the point where the ladder touches the building? Why was the South a good place for growing crops? What benefits does target receive from its store brand? A group of workers took 123.6 hours tocomplete a job. A smaller group of workerswill complete the same job, but it will takethem 1.15 times as long as it took the firstgroup. How long did it take the smaller groupto complete the job? Vagrancy laws in the 1860s applied to A) the property that African Americans were allowed to rent or own. B) people who moved from place to place without regular homes or work. C) the role of the planter aristocracy in Southern state legislatures. D) voter registration rights for newly freed African Americans in the South. show work1) n - 8 = -32) -2m=-243) m/2=-74) 2/3y=20(20 points for answers all) Which crime is a combination of theft and assault? what is cross products