import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Write a program to print numbers from 1 to 10.
for (int i = 1; i < 10; i++) {
System.out.println(i);
}
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Write a program to print numbers from 1 to 10.
int i = 1;
do {
System.out.println(i);
i++;
} while (i <= 10);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
/*
* Write a program to calculate the sum
* of 10 floating point numbers using for loop.
*/
float sum = 0;
for (int i = 1; i <= 10; i++) {
sum = sum + i;// sum+=i
}
System.out.println("sum==" + sum);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
/*
* Write a program to calculate the sum of 10 floating point numbers using for loop.
*/
float sum = 0;
for (int i = 1; i <= 10; i++) {
sum = sum + i;// sum+=i
}
System.out.println("sum==" + sum);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
/*
* write a program to calculate the sum of 10 floating point number.
*/
Scanner input = new Scanner(System.in);
float sum = 0, num;
for (float i = 1; i <= 10; i++) {
System.out.println("Enter any number:");
num = input.nextFloat();
sum = sum + num;
}
System.out.println("sum==" + sum);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
/*
* write a program that that asking the user to input a positive integer.It
* should than print the multiplication table of that number.
*/
Scanner input = new Scanner(System.in);
int num = input.nextInt();
for (int i = 1; i <= 10; i++) {
System.out.println(num + "*" + i + "=" + (num * i));
}
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
/* write a program to find the factorial value of any number */
// !4=4*3*2*1=24
// !5=5*4*3*2*1=120
Scanner input = new Scanner(System.in);
System.out.println("Enter any number:");
int num = input.nextInt();
int f = 1;
for (int i = num; i >= 1; i--) {
f = f * i;
}
System.out.println("factorial==" + f);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
/*
* Write a program that enters 10 integer number from the user,and then prints
* the sum of the even and odd integers
*/
Scanner input = new Scanner(System.in);
int num, sumEven = 0, sumOdd = 0, i = 0;
while (i < 10) {
System.out.println("Enter integer number:");
num = input.nextInt();
if (num % 2 == 0) {
sumEven = sumEven + num;
} else {
sumOdd = sumOdd + num;
}
i++;
}
System.out.println("The sum of Even numbers==" + sumEven);
System.out.println("The sum of Odd numbers==" + sumOdd);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
/*
* Write a program that enters 10 integer number from the user,and then prints
* the sum of the even and odd integers
*/
Scanner input = new Scanner(System.in);
int num, sumEven = 0, sumOdd = 0, i = 0;
int countEven = 0, countOdd = 0;
while (i < 10) {
System.out.println("Enter integer number:");
num = input.nextInt();
if (num % 2 == 0) {
countEven++;
} else {
countOdd++;
}
i++;
}
System.out.println("The sum of Even numbers==" + countEven);
System.out.println("The sum of Odd numbers==" + countOdd);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
// 1+ 1/2 + 1/3 + 1/4 + 1\5 +.......1/n
Scanner input = new Scanner(System.in);
int num = input.nextInt();
float sum = 0;
for (int i = 1; i <= num; i++) {
sum += 1.0 / i;
}
System.out.println("sum is=" + sum);
}
}
import java.util.Scanner;
public class Mohamed {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
float n, sum = 0.0f;
for (int i = 1; i <= 10; i++) {
System.out.println("Enter # " + i + " : ");
n = input.nextFloat();
sum += n;
}
float avg = sum / 10;
System.out.println("Avg==" + avg);
}
}