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
n200080 [17]
3 years ago
6

Java Eclipse homework. I need help coding this

Computers and Technology
1 answer:
kirill [66]3 years ago
6 0

import java.util.Scanner;

public class BaseConvertor {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Welcome to Base Convertor! This program will convert numbers into different bases of your choosing.");

       System.out.print("Do you still want to run the program? ");

       String ans = scan.next();

       if (ans.toLowerCase().equals("yes")){

           System.out.println("1. Octal");

           System.out.println("2. Binary");

           System.out.println("3. Hexadecimal");

           System.out.print("Type the number of the base you want to conver to: ");

           int base = scan.nextInt();

           System.out.print("Enter your number: ");

           int num = scan.nextInt();

           if (base == 1){

               

               String newNum = Integer.toOctalString(num);

               System.out.println(num+" in Octal is "+newNum);

           }

           else if (base == 2){

               String newNum = Integer.toBinaryString(num);

               System.out.println(num+" in Binary is "+newNum);

           }

           else if (base == 3){

               String newNum = Integer.toHexString(num);

               System.out.println(num+" in Hexadecimal is "+newNum);

           }

                   

       }

       else{

           System.out.println("Have a good day!");

       }

   }

   

}

I hope this helps!

You might be interested in
What type of strategy is being used by a website like www.CNNMoney when it describes itself as ""a one-stop destination covering
alina1380 [7]

Answer:

Positioning

Explanation:

One of the most important concept of marketing is Positioning. It is a marketing concepts that provides a description of what businesses must do to ensure its products are marketed and its services rendered to customers. When positioning your organization, the image of the organization's product is created with its intended audience in mind, by using promotion, place, product, and price.

4 0
3 years ago
Read 2 more answers
Which statement best describes one reason why assembly
posledela

Answer:

D. It allows programmers to write abbreviations instead of repeating calculations

7 0
2 years ago
Write measure five safety measures can be taken to stay safe in social media​
alexdok [17]

Answer:

  1. <u>Use a strong password</u>.
  2. <u>Use a different password for each of your social media accounts</u>.
  3. <u>Set up your security answers. </u>
  4. <u>If you have social media apps on your phone, be sure to password protect your device.</u>
  5. <u>Be selective with friend requests. </u>

5 0
3 years ago
Read 2 more answers
Suppose as a computer programmer, you have been assigned a task to develop a program to store the sorted data in ascending order
shepuryov [24]

Answer:

In case the data is arranged in the ascending order, you can always change the Binary search tree into a Height BST, and which is also known as the self-balancing BT. And through this, it's quite on hand to better the operations like searching on the new BST. And these SBBTs are quite commonly made use of for constructing as well as maintaining the ordered list. This is the case in the case of the priority queue, and this is what is required here.

Explanation:

Please check the answer.

3 0
4 years ago
What has prompted schools to add Internet activities in their academic integrity policies? a. New technological advancements c.
AysviL [449]

Answer:

A

Explanation:

Schools are trying to adjust to technology to help students.

6 0
3 years ago
Read 2 more answers
Other questions:
  • In the two-level directory, if a user refers to a particular file then__________________ Select one: a. only his/her own UFD (us
    7·1 answer
  • ​the unified modeling language (uml) represents an object as a _____ with the object name at the top, followed by the object's a
    7·1 answer
  • Assume a 8x1 multiplexer’s data inputs have the following present values: i0=0, i1=0, i2=0, i3=0, i4=0, i5=1, i6=0, i7=0. What s
    8·1 answer
  • A company has decided to re-introduce a retro-radio by reproducing a product that was manufactured in the 1940s. The company has
    5·1 answer
  • How many bits are in 1 tb? [hint: depending on the tool used to calculate this, you may need to use a trick to get the exact res
    6·1 answer
  • Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
    14·1 answer
  • A _______ object is used for storing data.
    9·2 answers
  • NAND is logically complete. Use only NAND gates to constructgate-level circuits that compute the
    7·1 answer
  • Write the program to accept the radius of circle and find its diameter coding
    11·1 answer
  • What is a common indicator of a phishing attempt cyber awareness 2022
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!