import java.util.*;
import java.lang.*;
import java.io.*;
class Chegg
{
public static void main (String[] args) throws
FileNotFoundException
{
int sum=0;
double avg=0;
File file = new
File("C:/Users/Gaurav/Documents/input.txt");
Scanner scanner = new
Scanner(file);
while (scanner.hasNext())
{
if(scanner.hasNextInt())
{
int num=scanner.nextInt();
sum=sum+num;
}
else
scanner.next();
}
avg=(sum*1.0)/10;
System.out.println("The sum is
"+sum+" and average is "+avg);
}
}
Sample Input:-
Sample Output:-
The sum is 55 and average is 5.5
java in simple way pla help me 1. Write a program that uses a while loop...
JAVA Restrictions 1. don't use any other way to implement a loop but recursion (while and for are forbidden). 2. don't use Math.pow\ 3. Pls do not use while or for 1. write a class called MultiplyByItself with a main method 2. the program asks for two integer numbers: x and n. n must be 0 or greater than 0. 3. then the program prints x raised to the n-th power. For example if x is 2 and n is...
Write a program that prints the following console output using the while-loop and for-loop D not use if-else, setw) and ciomanip> for this problem. .Before you open a Word file to copy the screen shots, tell Dr. Jo. Save the Word file as your name in your flash drive. .Take a screen-shot the code and paste to the Word file. (5 points). Take a screen-shots of the console output and paste to the Word file. (5 points) Save the Word...
This is a C program. please help me to write a pseudocode of the program . also, I want the program In a do...while loop and the screen output should look like in the picture. please help me. 3.1. Write a program that asks the user to continue to enter two numbers (at a time). For each pair of numbers entered, the program calculates the product of those two numbers, and then accumulate that product. For each pair of numbers...
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25.
Write a python program that uses a while loop to print numbers 100,98,96... all the way to 0. each number should be printed on a seperate line
C program. Using do-while loop for this question. Question: write a program to calculate the average of first n numbers. output: Enter the value of n : 18 The sum of first 18 numbers =171 The average of first 18 numbers = 9.00 my code couldn't give me the right avg and sum. Please help. #include<stdio.h> int main() { int num; int count =0; int sum=0; float avg; printf("Enter the value of n: "); ...
Please write a java program that inputs positive numbers using a while loop until a negative number is input and finds the sum of the numbers input
Write a Java program which uses a for loop to sum all the even numbers from 1 to 30.
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to input 10 int numbers from the user...
Java Submit a program in a .java file. The program should print a multiplication table for the numbers 1-9. This requires a nested for loop. The outer loop moves from row to row, while the inner loop prints the row. Use tabs to separate the output, such as in the following statement: System.out.println(“1\t2\t3\t4\t5\t6\t7\t8\t9”); Output should look similar to the following. 1 2 3 4 5 6 7 8 9 ------------------------------------------------------------------ 1 2 3 4 5 6 7 8 9...