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
Paladinen [302]
3 years ago
15

Write a program that reads three whole numbers and displays the average of the three number. Sample Run #: java Average3 Interac

tive Session.
1. Enter the first integer: 8
2. Enter the second integer: 10
3. Enter the third integer: 18
The average of 8, 10, and 18 = 12.0.
Computers and Technology
1 answer:
Maksim231197 [3]3 years ago
4 0

Answer:

The program to this question as follows:

Program:

import java.util.*; //import package

class Average //defining class Average

{

public static void main(String[] args) //defining main method

{

int a1,b2,c3;//defining integer variable

float avg; //defining float variable

Scanner obz=new Scanner(System.in); //creating scanner class object

System.out.print("input first number: "); //print message

a1=obz.nextInt(); //input value by user

System.out.print("input second number: "); //print message

b2=obz.nextInt(); //input value by user

System.out.print("input third number: "); //print message

c3=obz.nextInt(); //input value by user

avg=a1+b2+c3/3; //calculating average

System.out.print("The average of "+a1+","+b2+",and "+ c3+"="+ avg);//print value    

}

}

Output:

input first number: 8

input second number: 10

input third number: 18

The average of 8,10,and 18=24.0

Explanation:

In the above code, a class "Average" is defined inside this class the main function is declared in this method three integer variable "a1, b2, and a3" is declared, which input the value from the user side. in this method, a float variable avg is defined that calculates its average value.

  • In the next step, a scanner class object is created, that uses the above integer variable values.  
  • In the "avg" variable add all integer variables then divide its value by 3. At the print, method is used that prints avg variable value.
You might be interested in
Date Time Manipulation Exploration If you start from Jan 1st, 1757, and repeatedly add 8 days, until you hit 1800, how many time
zimovet [89]

Answer:

from datetime import datetime, date, timedelta

def count_weekdays(start_date, add_days, stop_year, weekday):

   my_date = start_date

   m = 0  

   while my_date.year != stop_year:  

       my_date = my_date + timedelta(days = add_days)

       if my_date.isoweekday() == weekday:

           m += 1

   return m

date_val = date(1757,1,1)

try:

   date_val = datetime.fromisoformat(input("Enter date in the format yyyy-mm-dd: "))

except ValueError:

   print("Wrong isoformat string")

print(count_weekdays(date_val, 8, 1800, 1))

Explanation:

The datetime package of the python programming language has several time modules like the date, datetime, pytz, timedelta, etc, used to manipulate date and time in documents. The function count_weekdays has four parameters and returns the number of a specified weekday in a period of time.

4 0
3 years ago
Many financial experts advise that property owners should insure their homes or buildings for at least 80 percent of the amount
serious [3.7K]
All I will say is good luck. because it can be very difficult to find someone that is willing to do this.
5 0
3 years ago
To create a window, which of thefollowing classes has to be extended?ContainerJFrameJButtonJTextField
irga5000 [103]

Answer:

J frame class has to be extended for the creation of a window

Explanation:

J frame needs to be extended to create a window, this is because this class in windows has a title, support buttons components, a border or we can say it has decorations for windows.  

The rest of the classes like J button and J text fields lie within the J frame and the Container class is a super class and provides only outlines to J Frame class.

3 0
2 years ago
What is the effective address generated by the following instructions? Every instruction is
kaheart [24]
D. Mov ax, [bx+si] is your answer
5 0
2 years ago
Write a "for loop" that displays a string in the reverse order (DO NOT use the reverse method) 3.
elena55 [62]

Following are the code in java to reverse any string without using reverse function.

import java.util.*; // import package

class Main // class

{

public static void main(String args[])  // main class in java

{

String s, r = "";  // string variable

Scanner out = new Scanner(System.in);  // scanner classes to take input

System.out.println("Enter a string to reverse");

s = out.nextLine();  // input string

int l1 = s.length();  // finding length of string

l1=l1-1;

for ( int i = l1 ; i >= 0 ; i-- )  // for loop to reverse any string

{

r = r + s.charAt(i);

}

System.out.println(" The Reverse String is: "+r);  // print reverse string

  }

}

Explanation:

firstly we input any string ,finding the length of that string then after that iterating over the loop by using for loop and last display that reverse string

output

Enter a string to reverse

san ran

The Reverse String is: nar nas

5 0
3 years ago
Other questions:
  • There are two types of short-term memory: one type is involved in the input and storage of new information, the other type of sh
    9·1 answer
  • A general rule for adding text to a slide is ____.
    8·2 answers
  • The incident results in huge losses of revenue as a result their mobile app service is withdrawn. Investigators discovered a vul
    5·1 answer
  • Tony is in charge of all presentations for a Fortune 500 pharmaceutical company. In addition to creating powerful and persuasive
    9·1 answer
  • 2 (01.01 LC)
    5·1 answer
  • How do u delete a post on brainly
    7·1 answer
  • What is the best way of farming exotics in destiny?
    12·2 answers
  • 10. Two technicians are discussing recycling specifications for refrigerant. Technician A says that refrigerant oil with 5,000 p
    9·1 answer
  • Explain why it is important that the device registration is the last thing that is done in the initialization routine of a devic
    10·1 answer
  • After a group sets a project schedule, members should be prepared to
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!