Answer:
Explanation:
The following code is written in Java and like requested prompts the user for a number to continue or a letter to exit. Then loops and keeps adding all of the numbers to the sum variable and adding 1 to the count for each number entered. Finally, it prints the sum and the average using printf and the variables.
import java.util.Scanner;
class Examine1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int sum = 0;
int count = 0;
System.out.println("Enter a number to continue or a letter to exit.");
while(in.hasNextInt()) {
System.out.println("Enter a number:");
sum += in.nextInt();
count += 1;
}
System.out.printf("The sum is %s.%n", sum);
System.out.printf("The average is %s.", (sum / count));
}
}
Add a pic i cant tell what you talking about
Answer:
Explanation:
Let's do this in Python, we shall use the package random to generate a random double between 0 and 1. Then we multiply it with 50 and covert to integer to get a random integer between 0 and 50. Place a While function with condition to stop when it's greater than 25
from random import random
attempts = 1
random_int = int(random()*50)
print(random_int)
print("This is attempt " + attempts)
while random_int <= 25:
attempts += 1
random_int = int(random()*50)
print(random_int)
print("This is attempt " + attempts)