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
shutvik [7]
3 years ago
10

Write a program that accepts any number of homework scores ranging in value from 0 through

Computers and Technology
1 answer:
Dimas [21]3 years ago
6 0

Answer:

This program is written in Java programming language.

It uses an array to store scores of each test.

And it also validates user input to allow only integers 0 to 10,

Because the program says the average should be calculated by excluding the highest and lowest scores, the average is calculated as follows;

Average = (Sum of all scores - highest - lowest)/(Total number of tests - 2).

The program is as follows (Take note of the comments; they serve as explanation)

import java.util.*;

public class CalcAvg

{

public static void main(String [] args)

{

 Scanner inputt = new Scanner(System.in);

 // Declare number of test as integer

 int numTest;

 numTest = 0;

 boolean  check;

  do

  {

   try

   {

     Scanner input = new Scanner(System.in);

    System.out.print("Enter number of test (1 - 10): ");

    numTest = input.nextInt();

    check = false;

    if(numTest>10 || numTest<0)

     check = true;

   }

   catch(Exception e)

    {

     check = true;

   }

  }

  while(check);

  int [] tests = new int[numTest];

//Accept Input

for(int i =0;i<numTest;i++)

{

System.out.print("Enter Test Score "+(i+1)+": ");

tests[i] = inputt.nextInt();

}

           //Determine highest

           int max = tests[0];

           for (int i = 1; i < numTest; i++)

           {

               if (tests[i] > max)

               {

                   max = tests[i];

               }

           }

           //Determine Lowest

           int least = tests[0];

           for (int i = 1; i < numTest; i++)

           {

               if (tests[i] < least)

               {

                   least = tests[i];

               }

           }

           int sum = 0;

           //Calculate total

           for(int i =0; i< numTest;i++)

           {

               sum += tests[i];

           }

           //Subtract highest and least values

           sum = sum - least - max;

           //Calculate average

           double average = sum / (numTest - 2);

           //Print Average

           System.out.println("Average = "+average);

           //Print Highest

           System.out.println("Highest = "+max);

           //Print Lowest

           System.out.print("Lowest = "+least);

}

}

//End of Program

You might be interested in
Create a new file that builds a shopping list from a user. There should be a input query that asks the user to list an item and
levacccp [35]

Answer:

Check the output

Explanation:

# -*- coding: utf-8 -*-

"""

Created on Thu Apr 12 00:39:11 2018

author:

"""

stocks ={

       "tomato soup": 20,

       "cheese": 8,

       "bread": 6,

       "milk": 8,

       "butter": 7,

       "coffee": 8,

       "ice cream": 5,

       "orange juice": 12,

       "bacon": 6,

       "tortilla chips": 14,

       "ramen": 24 }

prices ={

       "tomato soup": 1.85,

       "cheese": 3.99,

       "bread": 2.50,

       "milk": 3.59,

       "butter": 1.99,

       "coffee": 5.99,

       "ice cream": 2.99,

       "orange juice": 2.50,

       "bacon": 5.49,

       "tortilla chips": 3.00,

       "ramen": 0.99 }

def grocery_cost(item_list,quantity_list):

   totalcost = 0

   for i in range(len(item_list)):

       totalcost=totalcost+(quantity_list[i]*prices[item_list[i]])

       

   return totalcost

def stock(item):

   print("Number of itmes present in the stock:",stocks[item])

print("Welcome to the on-line grocery store!!")

print("Items that are available for purchase:")

for key in stocks.keys():

   print(key)

#chosen foods

print("Enter the item with quantity or Enter 'Q' when you are done")

item_list=[]

quantity_list=[]

while True:

   item=input('Enter the item name: ')

   if item=='Q' or item=='q':

       break

   item_list.append(item)

   while True:

       quan=int(input('Enter the number of item: '))

       if stocks[item] >=quan:

           quantity_list.append(quan)

           break

       else:

           stock(item)

           print('Your requirement is higher than stock available. Please enter again!!')

print("\nTotal cost:", "$",grocery_cost(item_list,quantity_list))

Kindly check the output in the attached image below.

7 0
3 years ago
Percentage-wise, which renewable energy source is used most?
Natasha2012 [34]
C)Hydroelectric I believe.
5 0
3 years ago
A_______VPN connection is a private network that uses a public
goldfiish [28.3K]

Answer:

letter c. point to site po sagot diyan

3 0
2 years ago
What makes an active heat sink different from a passive heat sink?
zimovet [89]
An active heat sync will keep a computer cool and basically cool the CPU and processors. A passive heat sink will only cool the CPU and whatever else it needs to cool when the CPU actually NEEDS to be cooled. I am not sure if this is all correct but I know about basic heat syncs and from my understanding this is right.
8 0
3 years ago
What security weaknesses/vulnerabilities exist in Wireless local area network device hardware and software?
AfilCa [17]

Answer:

Explanation:

There are many weaknesses/vulnerabilities, some of which are the following...

Default Network Hardware, many individuals will go out and buy a new router and install it in their home. These devices come with a preset configuration including a preset security password which is many times a default password used for every router of the same model. This can be easily obtained by anyone who can then access the network.

Access Point hacking, an experienced individual can use a packet sniffer to detect the SSID that is frequently sent from the router in order to create an access point to be able to access the network.

WEP encryption is another vulnerability. These are very low security passwords that can be cracked using different software in a short period of time.

These are some of many vulnerabilities that wireless local networks have, but there are also many precautions and security measures that can be taken to prevent them.

7 0
2 years ago
Other questions:
  • The class Date has a single constructor that accepts the integer value: a month- (1 for January through 12 for December), a day
    13·1 answer
  • What does computer means?
    13·2 answers
  • Which of the following topics is too broad for a 10-minute speech? A. classes offered in interior design B. the history of moder
    13·2 answers
  • The program used to create the file where you want to insert the object is called the ____.
    12·1 answer
  • Multiple Intelligence Theory explains that...
    8·2 answers
  • PACIFIC NORTHWEST
    10·1 answer
  • By what decade were books readily available to the public across the United States and Europe?
    7·1 answer
  • Demons I shall be your eternal nightmare
    13·1 answer
  • Hypertext enables you to navigate through pieces of information by clicking the __________, that connect them.
    8·1 answer
  • what must you consider when determining the efficiency of an algorithm? select two choices. group of answer choices the amount o
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!