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
​Case-Based Critical Thinking Questions​Case 9-1Melissa, a computer science engineering student, is learning the basics of progr
Sunny_sXe [5.5K]

Answer:

Option D:  monthName.splice(2, 3, "Mar", "Apr", "May");

Explanation:

splice is a JavaScript array method which can be used to insert or remove item(s).

It has general syntax:  splice( i, n , item1, item2, item3, .... , itemX)

  • i : index position of the array where the item should be inserted or removed
  • n: number of item(s) should be removed starting from index-i
  • item1,item2,....itemX :  item(s) to be inserted

If we have an original monthName array with elements:

["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

monthName.splice(2, 3, "Mar", "Apr", "May")  will

  • remove 3 items from index position-2 ("March", "April" and "May")
  • and insert three new items, "Mar", "Apr" and "May".

New array:

["January", "February", "Mar", "Apr", "May", "June", "July", "August", "September", "October", "November", "December"]

4 0
3 years ago
Dr. Joon asks her students how to insert a table in an Excel workbook. The students record the steps a chart. Which students lis
Leona [35]

Answer:

C

Explanation:

Both Table and Format as Table can be used to create a table

4 0
4 years ago
Write a program in Java programming language to display or calculate “Hello, Daddy and Mum”
olganol [36]

Answer:

class Simple{

public static void main(String args[]){

System.out.println("Hello Daddy and Mum);

}

}

Explanation:

First, we create a class, then a method and then give the Integrated Data Environment (IDE) the command to give out an output that says Hello, Daddy and Mum”

8 0
3 years ago
Assume we have a two-class learning problem where the labeled data consists of 1,000 data points from one class, and 10 data poi
lakkis [162]

Answer:

I don't know

Explanation:

please just thank me I need the points

4 0
4 years ago
A __________ is created by using a secure hash function to generate a hash value for a message and then encrypting the hash code
Maslowich
A Cryptographich hash is created by using a secure hash function to generate a hash value for a message and then encrypting the hash code with a private key.
3 0
3 years ago
Other questions:
  • A newspaper publishes a negative editorial on how local politicians are dragging their feet in building a new bridge. Select the
    5·2 answers
  • True or false over the course of ecological succession,species diversity increases over time?
    12·2 answers
  • 18. Which type of briefing is delivered to individual resources or crews who are assigned to operational tasks and/or work at or
    14·1 answer
  • A flowchart that depicts the relationships among the input, processing, and output of an AIS is
    6·1 answer
  • A(n) ____ is a location on your computer screen where you type text entries to communicate with the computer’s operating system.
    9·2 answers
  • PLEASE HELP
    8·2 answers
  • Which tab should you choose to add a picture from a file to your presentation?
    8·1 answer
  • Which file is usually the first file to be displayed when you navigate to a website?
    7·1 answer
  • Which is a connectionless protocol in the transport layer? What are the small chunks of data called?
    12·2 answers
  • When does if(x==y) execute?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!