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
Slav-nsk [51]
3 years ago
9

Write a program that will use user input. The program should be called PrintNumberToWordie which prints "ONE", "TWO",..., "FIVE"

UP to TEN if the int variable "number" is 1, 2,..., 5, 10, respectively be sure to code for the else/default option if no match is found.
This program must Use (a) a "nested-if" statement to complete; (b) Secondly the program must have an additional if statement to check to see if the user input is divisible by 2.
Computers and Technology
1 answer:
andrezito [222]3 years ago
5 0

Answer:

import java.util.Scanner;

public class PrintNumberToWordie {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a number");

       int num = in.nextInt();

       if(num == 1){

           System.out.println("ONE");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 2){

           System.out.println("TWO");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 3){

           System.out.println("THREE");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 4){

           System.out.println("FOUR");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 5){

           System.out.println("FIVE");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 6){

           System.out.println("SIX");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 7){

           System.out.println("SEVEN");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 8){

           System.out.println("EIGHT");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 9){

           System.out.println("NINE");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else if (num == 10){

           System.out.println("TEN");

           if(num%2==0)

               System.out.println("Divisible by 2");

       }

       else{

           System.out.println("No Match");

       }

 }

}

Explanation:

  • Using Java programming language
  • Import Scanner class
  • Prompt user to enter a number, receive and store in a variable
  • Use if and else if statements to check the value of the number and output the corresponding spelling
  • Use and inner if statement to check divisibility by two using the modulo operator
You might be interested in
Alex works as a customer-service representative at an insurance company. Before starting his shift, Alex reviews issues from his
never [62]

Answer:

problem-solving

Explanation:

he is making sure all his problems have been resolved before starting a new shift.

4 0
3 years ago
Read 2 more answers
Declared inside a function and is only available within the function in which it is declared.
vitfil [10]

Answer:

2b2t

Explanation:

2b2t

3 1
3 years ago
PLEASE HELP!! In Tynker does anyone know how to do the physics cannon assignment?
madam [21]

Answer: really u want help with a game

Explanation:

7 0
3 years ago
Read 2 more answers
) Suppose algorithm A takes 10 seconds to handle a data set of 1000 records. Suppose the algorithm A is of complexity O(n2). Ans
Mice21 [21]

Answer:

i) The time taken for 1500 records = 15 seconds.

ii) The time taken for 1500 records = 50 seconds.

Explanation:

A is an O(n) algorithm.

An algorithm with O(n) efficiency is described as a linearly increasing algorithm, this mean that the rate at which the input increases is linear to the time needed to compute that algorithm with n inputs.

From the question, it is given that for 1000 records, the time required is: 10 seconds.

Algorithm time taken is O(n)

Hence,

1) For 1,500 records

=> 10/1000 = x/1500

=> 10x1500/1000 = x

x = 15 seconds

Thus, the time taken for 1500 records = 15 seconds.

2) For 5,000 records

=> 10/1000 = x/5000

=> 10x5000/1000 = x

x = 50 seconds

Thus, the time taken for 1500 records = 50 seconds.

8 0
3 years ago
WHAT DO I DO IN MY FREE TIME????
yanalaym [24]

Answer:

what do u mean

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Network id is 192.168.10.32/28. what would be the ip address, if you assign the last available ip address in the range
    14·2 answers
  • 10 points!!!! Giving brainly to correct answers ! how do you make your questions wroth 5 points? mine only goes down to 10 >:
    15·1 answer
  • Which is not the option applicable to the technology reference framework for advanced countries?
    11·1 answer
  • Samantha was calculating a mathematical formula on an electronic spreadsheet. She used multiple values to recalculate the formul
    7·2 answers
  • What is C.R.A.T systems used for?
    9·1 answer
  • A set of parentheses that contain zero or more arguments
    12·1 answer
  • What Temperature does mainframe need
    15·2 answers
  • Which is better Play Station Xbox or PC
    14·2 answers
  • Match the image to the view type in a presentation program. scroll bar tool bar status bar menu bar provides an array of buttons
    10·2 answers
  • Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!