0% found this document useful (0 votes)
19 views3 pages

Eman Lab#6

The document discusses 4 programming tasks: 1) write a program to print a table of values using loops, 2) write a program to calculate the sum of squares of numbers using a while loop, 3) write a program to take user input as an array and find the minimum value, 4) determine the output of a given program that prints patterns based on odd/even counts.

Uploaded by

shagufta yaseen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Eman Lab#6

The document discusses 4 programming tasks: 1) write a program to print a table of values using loops, 2) write a program to calculate the sum of squares of numbers using a while loop, 3) write a program to take user input as an array and find the minimum value, 4) determine the output of a given program that prints patterns based on odd/even counts.

Uploaded by

shagufta yaseen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Task 3: Write a test program that takes some values from user and stores in an array, and finds

out
the minimum value from an array.

Task 1: Write a Java application that uses looping to print the following table of values:

public class TableOfValues {


public static void main(String[] args) {
System.out.println("N\t10°N\t100°N\t1000 N");
for (int i = 1; i <= 5; i++) {
System.out.print(i + "\t");
for (int j = 1; j <= 3; j++) {
System.out.print(i * Math.pow(10, j) + "\t");
}
System.out.println();
}
}
}
Output

Task 2: Write a program using while loop which calculate square of every number and then sum
the squares of all numbers. Output should be like as shown below: Marks: 3
import java.util.Scanner;
public class SquareSumCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Marks: ");
int count = scanner.nextInt();
int sum = 0;
int i = 1;
while (i <= count) {
int square = i * i;
System.out.println(square);
sum += square;
i++;
}
System.out.println("Total is " + sum);
}
}

Output:
Task 4: What does the following program print? Marks: 1

public class task3 {


public static void main(String[] args) {
int count = 1;
while ( count <= 10 ) {
System.out.println( count % 2 == 1 ? "****" : "++++++++" );
++count;
}
}
}

You might also like