Java_Assignment(Questions 1 - 8)
Java_Assignment(Questions 1 - 8)
package Assignment;
}
===================================================================================
==============
2] Write a program to calculate the sum of first 10 natural number.
package Assignment;
}
===================================================================================
================
3] Write a program to find the factorial value of any number entered through the
keyboard.
package Assignment;
import java.util.Scanner;
}
===================================================================================
=================
4] Two numbers are entered through the keyboard. Write a program to find the value
of one number raised to the power of another.
package Assignment;
import java.util.Scanner;
import java.math.*;
}
===================================================================================
===================
5] Write a program to sum of digits of given integer number.
package Assignment;
import java.util.Scanner;
import java.math.*;
}
System.out.println("Sum of digit is: " + sum);
}
===================================================================================
=====================
6] Write a program to check given number is prime or not.
package Assignment;
import java.util.Scanner;
}
===================================================================================
========================
7] Write a program to enter the numbers till the user wants and at the end it
should display the count of positive, negative and zeros entered.
package Assignment;
import java.util.Scanner;
int num=sc.nextInt();
if(num==0)
{
counterZero++;
}
else if(num<0)
{
counternegative++;
}
else
{
counterpositive++;
}
}
System.out.println("no of zeros:"+counterZero);
System.out.println("no of negative numbers: " + counternegative);
System.out.println("no of positive numbers: " + counterpositive);
}
===================================================================================
==========================
8] Write a program to enter the numbers till the user wants and at the end it
should display the maximum and minimum number entered.
package Assignment;
import java.util.Scanner;
public class Question8 {
System.out.println("======");
for(int i=1;i<size;i++)
{
if(min>a[i])
{
min=a[i];
}
}
System.out.println("Minimum value is " + min);
}
}
===================================================================================
============================
Get the following pattern:-
C]1
11
111
1111
11111
package Assignment;
public class QuestionC {