Running head: ASSIGNMENT 1 1
Program + Course Name
Section Code
Semester Fundamentals of Computer
IN2203-G6
ISBA II Science
Type of Evaluation Percentage Weight of Total
Assignment #1 (Online Evaluation
Winter 2021
Assignment) 15%
Course
Due Date
Instructor Total Marks: /15
Week 6 (Feb 15, 2021)
Abiodun Ojo
Student Name: Dilpreet Kaur Student ID #: 201906298
Student Name: Narmada Kethireddy Student ID #: 201906957
Student Name: Jaideep Singh Student ID #: 201906773
Student Name: Rattan Kaushal Student ID #: 201906803
Student Name: Sushant Singh Student ID #: 201904652
Instructions:
Design and document your response. Zip your codes along with your response back in this
document, and SUBMIT it back using Google Classroom once completed.
ASSIGNMENT 1 2
Tasks
1. This is Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, Write Java program to solve
the task.
Java code:
class Fibonacci{
public static void main(String args[])
int n1=0,n2=1,n3,i,count=10;
[Link](n1+" "+n2); //printing 0 and 1
for(i=2;i<count;++i)
n3=n1+n2;
[Link](" "+n3);
n1=n2;
n2=n3;
Output:
ASSIGNMENT 1 3
2. Write a Java program to Generate the Multiplication table below
6*1=6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 56
6* 10 = 60
Java Code:
public class Table
public static void main(String[] args) {
int num =6;
for(int a=1; a<=10; ++a)
ASSIGNMENT 1 4
[Link]("%d * %d = %d \n",num,a,num * a);
Output:
3. Factorial of n (n!) = 1 * 2 * 3 * 4 * ... * n. Write a Java program to find it.
Java code
import [Link];
class Factorial{
public static void main(String args[]){
int i,fact=1;
int num;
Scanner sc = new Scanner([Link]);
[Link]("\n Enter num");
num=[Link]();
for(i=1;i<=num;i++){
fact = fact*i;
[Link]("\n Factorial of "+num+" is "+fact);
ASSIGNMENT 1 5
} }
Output:
4. A prime number is a number divisible by only 1 and itself. Write a prime number
codes using Java.
Java Code:
public class Prime{
static void checkPrime(int n){
int i,m=0,flag=0;
m=n/2;
if(n==0||n==1){
[Link](n+" is not prime number");
}else{
for(i=2;i<=m;i++){
if(n%i==0){
ASSIGNMENT 1 6
[Link](n+" is not prime number");
flag=1;
break;
if(flag==0) { [Link](n+" is prime number"); }
}//end of else
Output:
5. Program to Find Standard Deviation:
Java Code:
public class StandardDeviation {
public static void main(String[] args) {
ASSIGNMENT 1 7
int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
double standardDeviation = calculateStandardDeviation(array);
[Link]("Standard deviation : %.6f", standardDeviation);
private static double calculateStandardDeviation(int[] array)
// finding the sum of array values
double sum = 0.0;
for (int i = 0; i < [Link]; i++) {
sum += array[i];
// getting the mean of array.
double mean = sum / [Link];
// calculating the standard deviation
double standardDeviation = 0.0;
for (int i = 0; i < [Link]; i++) {
standardDeviation += [Link](array[i] - mean, 2);
return [Link](standardDeviation/[Link]);
Output:
ASSIGNMENT 1 8