Essay by   •  November 9, 2015  •  Exam  •  1,998 Words (8 Pages)  •  1,207 Views

## Essay Preview: Programming Exam Answers

Report this essay
Page 1 of 8

Assignment 6 :

Name : Sayed Faqir Bares

Matric: 1320587

Section : 02

x is 60

The size of numbers is 30

2 and 5

1. double d[] = new double [10];
2. d[9]=5.5;

c)    System.out.println (d[0]);

System.out.println (d[1]);

d)

int min=d[0];

for (int I = 1 ;i<10;i++)

{

If (d[i]

min=d[i];

}

System.out.println (min);

1. The main cant be static because it takes nonstatic String varible
2. Cant declare size of array like this double [100] r ;
3. The function of length don’t take parameter.
4. r(i) should be r[i]
5. The function of random  take parameter.

111111

import java.util.Scanner;

public class AssignScore {

public static void main(String args[]){

Scanner input = new Scanner(System.in);

System.out.println("Enter the number of students : " );

int size = input.nextInt();

double [] student = new double[size];

System.out.print("Enter "+size+" score : \t" );

for (int i = 0;i<size;i++)

{

student[i] = input.nextInt();

}

double max = student[0];

for (int i = 1;i<size;i++)

{

if (student[i] > max )

max=student[i];

}

for (int i = 0 ; i<size;i++)

{

if (student[i] >= max-10)

else if(student[i] >= max-20)

else if (student[i] >= max-30)

else if (student[i] >= max-40)

else

System.out.println("Student "+i+" score is "+student[i]+"and Score is "+grade);

}

}

}

import java.util.Scanner;

public class CountOccurrenceOfNumbers {

public static void main(String args[]){

Scanner input = new Scanner(System.in);

int i=-1;

int [] student = new int [100] ;

System.out.println("Enter the integers between 1 and 50: " );

do

{

i++;

student[i] = input.nextInt();

}

while (student[i] != 0);

...

...