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
Alexandra [31]
3 years ago
7

Write a program that repeatedly takes integers from the user as long as he

Computers and Technology
1 answer:
Scorpion4ik [409]3 years ago
7 0

Answer:

Written in Python:

evens = 0

odds = 0

oddtotal = 0

eventotal = 0

total = 0

mylst = []

tryag = "Y"

while tryag == "Y" or tryag == "y":

     num = int(input("Input: "))

     mylst.append(num)

     tryag = input("Another Input (Y/y): ")

mylst.sort()

print("Minimum: "+str(mylst[0]))

print("Maximum: "+str(mylst[-1]))

for i in mylst:

     total = total + i

     if i%2 == 0:

           evens = evens + 1

           eventotal = eventotal + i

     else:

           odds = odds + 1

           oddtotal = oddtotal + i

print("Evens: "+str(evens))

print("Odds: "+str(odds))

print("Even Average: "+str(eventotal/evens))

print("Odd Average: "+str(oddtotal/odds))

print("Total Average: "+str(total/(evens+odds)))

Explanation:

The following lines initializes useful variables to 0

evens = 0

odds = 0

oddtotal = 0

eventotal = 0

total = 0

This declares an empty list

mylst = []

tryag = "Y"

This is repeated until user stops the loop by entering strings other than y or Y

while tryag == "Y" or tryag == "y":

This prompts user for input

     num = int(input("Input: "))

User input is appended to the list

     mylst.append(num)

This prompts user to try again the loop

     tryag = input("Another Input (Y/y): ")

This sorts the list from small to large

mylst.sort()

This prints 1. The minimum

print("Minimum: "+str(mylst[0]))

This prints 2. The maximum

print("Maximum: "+str(mylst[-1]))

The following iterates through the list

for i in mylst:

This calculates the total

     total = total + i

This checks for even entry

     if i%2 == 0:

This counts the number of even entries

           evens = evens + 1

This sums the even entries

           eventotal = eventotal + i

     else:

This counts the number of odd entries

           odds = odds + 1

This sums the odd entries

           oddtotal = oddtotal + i

This prints 3. Sum of Even entries

print("Evens: "+str(evens))

This prints 4. Sum of Odd entries

print("Odds: "+str(odds))

This prints 5. Average of Even entries

print("Even Average: "+str(eventotal/evens))

This prints 6. Average of Odd entries

print("Odd Average: "+str(oddtotal/odds))

This prints 7. Total Average

print("Total Average: "+str(total/(evens+odds)))

You might be interested in
What does =SUM(B2:B6) mean
dedylja [7]

In Excel the sum B2 and B6 simply means that B2 and B6 Numbers are adding to get a Sum, it actually like the normal Calculator, but in Excel it helps to do the calculation of your your data simple and easy, there is no hard work.

8 0
3 years ago
Why can’t I see one individual’s questions in the app through their profile, but I can see their questions on the website?
Mumz [18]

Answer:

I think thats just a software issue. i have the same problem

Explanation:

7 0
3 years ago
Read 2 more answers
WHAT DOES INFORMATION TECHNOLOGY DO??<br> Do they offer services or products
notsponge [240]
Yes

Explanation: Information technology, or IT, describes any technology that powers or enables the storage, processing and information flow within an organization. Anything involved with computers, software, networks, intranets, Web sites, servers, databases and telecommunications falls under the IT umbrella.
4 0
2 years ago
Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1.
alexira [117]

Answer:

15

Explanation:

01234567891011121314

5 0
2 years ago
Assume that the population of Mexico is 128 million and that the population increases 1.01 percent annually. Assume that the pop
horrorfan [7]

Answer:

//Define class

public class Main {

 //define main method

 public static void main(String[] args)  

 {

   //declare and initialize the double type variable to 128

   double mexico = 128;

   //declare and initialize the double type variable to 323

   double us = 323;

   //declare and initialize the integer type variable to 0  

   int yr = 0;

   //set the while loop to check which is greater

   while (mexico < us)  

   {

     //increment in the variable by 1

     yr++;

     //initialize in the variables acc. to the percentage

     mexico *= 1.0101;

     us *= 0.9985;

   }

   //print the following results

   System.out.println("Population of the Mexico will be exceed the population U.S. in " + yr + " years");

   System.out.println("Population of the Mexico will be " + mexico + " million");

   System.out.println("and population of the U.S. will be " + us + " million");

 }

}

<u>Output</u>:

Population of the Mexico will be exceed the population U.S. in81 years

Population of the Mexico will be 288.88435953355025 million

and population of the U.S. will be 286.0198193927948 million

Explanation:

<u>Following are the description of the program</u>.

  • Firstly, we define the class 'Main' and inside it, we define the main method.
  • Then, declare two double data type variables which are 'mexico' and 'us' and initialize in it to 128 and 323.
  • Declare integer data type variable 'yr' and initialize in it to 0.
  • Set the while loop and pass the condition to check that the variable 'mexico' is less than the variable 'us' then, increment in the variable 'yr' by 1 and multiply the variables 'us' and 'mexico' by the following percentage.
  • Finally, print the following results with the message.
6 0
3 years ago
Other questions:
  • Suppose you want to delete an existing file from within Word. What would you do? A. Click on the File button, choose Recent, ope
    9·1 answer
  • Design a method for representing the state of a tic-tac-toe board in computer memory. can you fit your representation into three
    12·2 answers
  • Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for ex
    11·1 answer
  • How to engage more underrepresented and under resourced students in stem programs?
    10·1 answer
  • Classify the functions of dhcp and dns protocols​
    14·1 answer
  • How do i fix this to make it run ???
    9·1 answer
  • Watson Studio is the IBM premier integrated development environment for data science and artificial intelligence practitioners.
    5·1 answer
  • Write a static method reOrder56(int[] nums) that return an array that contains exactly the same numbers as the given array, but
    10·1 answer
  • can you still receive messages on messenger from a person when you deleted the conversation with them? (But not blocked them)
    14·2 answers
  • Years ago when working a helpdesk, the most common question asked, almost daily, was about resetting passwords. What type of kno
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!