answer.
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
Bogdan [553]
2 years ago
4

Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the t

hree values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two methods. The method largestNumber() should return the largest number of the three input values. The method smallestNumber() should return the smallest number of the three input values. public static int largestNumber(int num1, int num2, int num3) public static int smallestNumber(int num1, int num2, int num3)
Computers and Technology
2 answers:
Alexeev081 [22]2 years ago
8 0

Answer:

#get input for numbers

a = int(input())

b = int(input())

c = int(input())

#set small to a

small = a

#if b is less then small

if b < small:

   small = b

   

#if c is less then small

if c < small:

   

#set small equall to c

small = c

#output the result

print(small)

Explanation:

Romashka [77]2 years ago
7 0

Answer:

The java program is as follows.

import java.util.Scanner;

import java.lang.*;

public class Numbers

{

//variables to hold three integers

static int num1, num2, num3;

//method to return largest of all three numbers

public static int largestNumber(int num1, int num2, int num3)

{

if(num1>num2 && num1>num3)

return num1;

else if(num2>num1 && num2>num3)

return num2;

else  

return num3;

}

//method to return smallest of all three numbers

public static int smallestNumber(int num1, int num2, int num3)

{

if(num1<num2 && num1<num3)

return num1;

else if(num2<num1 && num2<num3)

return num2;

else  

return num3;  

}

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter three numbers: ");

num1= sc.nextInt();

num2= sc.nextInt();

num3= sc.nextInt();

int largest = largestNumber(num1, num2, num3);

int smallest = smallestNumber(num1, num2, num3);

System.out.println("Largest number is "+ largest);

System.out.println("Smallest number is "+ smallest);

}

}

OUTPUT

Enter three numbers: 12 13 15

Largest number is 15

Smallest number is 12

Explanation:

1. Three integer variables are declared to hold the three user inputted numbers.  

2. The variables are declared static and declared at the class level.  

3. The method, largestNumber(), takes three numbers as parameters and returns the largest of all the three numbers. Hence, the return type of the method is int and declared as static.  

public static int largestNumber(int num1, int num2, int num3)  

4. The largest number is found using multiple if-else statements.  

5. The method, smallestNumber(), takes three numbers as parameters and returns the smallest of all the three numbers. Hence, the return type of the method is int and declared as static.  

public static int smallestNumber(int num1, int num2, int num3)  

6. The smallest number is found using multiple if-else statements.  

7. Inside main(), an object of Scanner class is created to enable user input.  

Scanner sc = new Scanner(System.in);  

8. The user is prompted to enter three numbers.  

9. The three numbers are passed as parameters to both the methods, largestNumber() and smallestNumber().  

10. Two integer variables, largest and smallest are declared. These variables hold the values returned from largestNumber() and smallestNumber() methods, respectively and displayed to the user.

You might be interested in
Write an expression that continues to bid until the user enters 'n'.
alisha [4.7K]

Answer:

1)

Add this while statement to the code:

while(keep_going!='n'):  

#the program keeps asking user to continue bidding until the user enter 'n' to stop.

2)

Here is the code for ACTIVITY 53.3. While loop: Insect growth:

num_insects = int(input())

while num_insects <= 100:

   print(num_insects, end=' ')

   num_insects = num_insects * 2

 

Explanation:

Here is the complete code for 1)

import random

random.seed (5)

keep_going='-'

next_bid = 0

while(keep_going!='n'):

   next_bid = next_bid + random.randint(1, 10)

   print('I\'ll bid $%d!' % (next_bid))

   print('continue bidding?', end='')

   keep_going = input()

Here the the variable keep_going is initialized to a character dash keep_going='-'

The statement keep_going = input() has an input() function which is used to take input from user and this input value entered by user is stored in keep_going variable. while(keep_going!='n'):  is a while loop that keeps iterating until keep_going is not equal to 'n'.    print('continue bidding?', end='')  statement prints the continue bidding? message on the output screen. For example the user enters 'y' when this message appears on screen. So keep_going = 'y' . So the operation in this statement next_bid = next_bid + random.randint(1, 10) is executed in which next_bid is added to some randomly generated integer within the range of 1 to 10 and print('I\'ll bid $%d!' % (next_bid))  prints the result on the screen. Then the user is prompted again to continue biffing. Lets say user enters 'n' this time. So keep_going = 'n'. Now the while loop breaks when user enters 'n' and the program ends.

2)

num_insects = int(input()) #the user is prompted to input an integer

while num_insects <= 100: #the loop keeps iterating until value of num_insects exceeds 100

   print(num_insects, end=' ') #prints the value of num_insects  

   num_insects = num_insects * 2 #the value of num_insects is doubled

For example user enters 8. So

num_insects = 8

Now the while loop checks if this value is less than or equal to 100. This is true because 8 is less than 100. So the body of while loop executes:

   print(num_insects, end=' ') statement prints the value of num_insects

So 8 is printed on the screen.

num_insects = num_insects * 2 statement doubles the value of num_insects So this becomes:

num_insects = 8 * 2

num_insects = 16

Now while loop checks if 16 is less than 100 which is again true so next 16 is printed on the output screen and doubled as:

num_insects = 16 * 2

num_insects = 32

Now while loop checks if 32 is less than 100 which is again true so next 32 is printed on the output screen and doubled as:

num_insects = 32 * 2

num_insects = 64

Now while loop checks if 64 is less than 100 which is again true so next 64 is printed on the output screen and doubled as:

num_insects = 64 * 2

num_insects = 128

Now while loop checks if 128 is less than 100 which is false so the program stops and the output is:

8 16 32 64  

The programs along with their output is attached.

7 0
2 years ago
Effective character encoding requires:
lidiya [134]

To answer your question the answer would be B compatible browsers

4 0
2 years ago
Identify the articulation site that allows us to nod our head ""yes"".
Luden [163]

Answer:

Occipital bone-atlas

Explanation:

The occipital bone is a bone that covers the back of your head; an area called the occiput. The occipital bone is the only bone in your head that connects with your cervical spine (neck).  The occipital bone surrounds a large opening known as the foramen magnum.

The foramen magnum allows key nerves and vascular structures passage between the brain and spine. Namely, it is what the spinal cord passes through to enter the skull. The brainstem also passes through this opening.

The foramen magnum also allows 2 key blood vessels traversing through the cervical spine, called the vertebral arteries, to enter the inner skull and supply blood to the brain

8 0
2 years ago
Your friends credit scores are 560, 675, 710, 590, and 640. Your credit score is 680. What is the difference between the average
Wittaler [7]

Answer:

560+675+710+590+640=3175/5=635

so your credit score is 45 credits better than the average of your friends

Explanation:

3 0
2 years ago
The Spinning Jenny reduced the number of workers necessary to _______. a.remove cotton seeds from fibers b.pump water from the m
bazaltina [42]

The answer is D: Turn yarn into cloth.

During the industrial revolution, a number of new inventions in the textile industry greatly impacted this industry. However, it was the invention of the Spinning Jenny that is credited a lot. It helped move the textile industry from homes to factories and made wool spinning easier and faster. This invention, however, impacted the labor workforce. It reduced the amount of work needed to produce yarn. One worker was able to work 8 or more spools at once and rose to 120 due to technological advancements.

5 0
2 years ago
Other questions:
  • What tool extends the basic functionality provided in task manager with additional features and tools?
    8·1 answer
  • Foods that are high in _________ have the least impact on slowing the body's absorption rate of alcohol.
    5·1 answer
  • Ben's team is working on an English project. The members want to see everyone's progress on their part of the project. What tech
    7·2 answers
  • Fill in the blank; "As well as their traditional role of computing data, computers are also extensively used for..."
    14·1 answer
  • Create a program to deteate a program to determine whether a user-specified altitude [meters] is in the troposphere, lower strat
    11·1 answer
  • When employees have multiple concurrent connections, what might be happening to the VPN system?
    7·1 answer
  • What text results in variable white space (blank) texts results In even white space
    9·1 answer
  • Write a function that takes a string like 'one five two' and returns the corresponding integer (in this case, 152). A function j
    11·2 answers
  • Array A is not a heap. Clearly explain why does above tree not a heap? b) Using build heap procedure discussed in the class, con
    15·1 answer
  • When should a developer begin thinking about scalability? 1 during the design phase 2during testing 3when traffic increases by 2
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!