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
Ostrovityanka [42]
2 years ago
8

This program needs to be written in Java. Along with NO For/while loops, and no methods.

Computers and Technology
1 answer:
Umnica [9.8K]2 years ago
6 0
The only way without a while loop and no method I can think of is use switch with every possible variation of the four digit binary which is 15.

Here is the starter code:

import java.util.Scanner;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int digit = sc.nextInt();
switch(digit) {
case 0000:
System.out.println("0");
break;
case 0001:
System.out.println("1");
break;
case 0010:
System.out.println("2");
break;
case 0011:
System.out.println("3");
break;
case 0100:
System.out.println("4");
break;

… (fill in other cases)


}
}
}

Use this link: https://www.electronics-tutorials.ws/binary/bin_3.html

There might be a better way, but without loops or methods this is all I got.
You might be interested in
True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer
sdas [7]
#1) If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type.
Answer: True. Any method that is not declared void must contain a return statement with a corresponding return value. The data type of the return value must match the method's declared return type; you can't return an integer value from a method declared to return a boolean.
5 0
3 years ago
Alex’s family members live in different parts of the world. They would like to discuss the wedding plans of one of their distant
goldenfox [79]
The answer would be b
8 0
3 years ago
Read 2 more answers
___are designed to infect and cause damage to operating system files, computer registry, and other locations on the motherboard
Firlakuza [10]

Answer:

Viruses

Explanation:

virusues are designed to infect and cause damage to operating system files, computer registry, and other locations on the motherboard

3 0
3 years ago
You are given a class named Clock that has one int instance variable called hours.
Vlad [161]

Answer:

public Clock(int hours) {

       this.hours = hours;

   }

Explanation:

In Java programming language, Constructors are special methods that are called to initialize the variables of a class when a new object of the class is created with the new keyword. Consider the complete code for the class below;

<em>public class Clock {</em>

<em>    private int hours;</em>

<em>    public Clock(int hours) {</em>

<em>        this.hours = hours;</em>

<em>    }</em>

<em>}</em>

In this example above,  an object of this class can created with this statement Clock myclock = new Clock(6); This is a call to the constructor and passes a parameter (6) for hours

7 0
2 years ago
Which of the following can be represented by a single binary digit?
Zinaida [17]

Answer:

  B.  The remainder when dividing a whole number by 2

Explanation:

A binary digit can have the values 0 or 1. The remainder from division of an integer by 2 will be 0 or 1. Hence that remainder can be represented by a single binary digit.

__

That fact can be used to do conversion of a number to binary.

8 0
3 years ago
Other questions:
  • Adam would like to reduce the size of an image that he inserted into a document. He selects the image and chooses the Crop optio
    11·2 answers
  • Mike is reading about machine-dependent programming languages. Which languages are machine-dependent programming languages?
    11·1 answer
  • Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one.
    11·1 answer
  • If you press the key corresponding to letter A on the keyboard, what process is carried out inside the CPU to display the letter
    10·1 answer
  • How can a user preview the playback of an audio clip in PowerPoint? Use the drop-down menus to complete the statements.
    14·1 answer
  • The term ____ describes primary storage devices that are implemented as microchips, can read and write with equal speed, and can
    8·1 answer
  • You can insert video by clicking video drop-down menu on the ______ tab.
    15·1 answer
  • Software que busca, detecta y elimina malware tipo espía; puede instalarse en la computadora de manera aislada o en conjunto con
    11·1 answer
  • PLS REPLY ASAP WILL MARK BRAINLIEST
    5·2 answers
  • Who is willam afton from five nights at freddy
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!