Programming Exam Answers
Essay by Sayed Bares • November 9, 2015 • Exam • 1,998 Words (8 Pages) • 1,285 Views
Assignment 6 :
Name : Sayed Faqir Bares
Matric: 1320587
Section : 02
Answer 1:
x is 60
The size of numbers is 30
Answer 2:
2 and 5
Answer 3:
- double d[] = new double [10];
- 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);
Answer 4:
- The main cant be static because it takes nonstatic String varible
- Cant declare size of array like this double [100] r ;
- The function of length don’t take parameter.
- r(i) should be r[i]
- The function of random take parameter.
Answer 5:
111111
ANSWER 6:
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++)
{
char grade;
if (student[i] >= max-10)
grade='A';
else if(student[i] >= max-20)
grade='B';
else if (student[i] >= max-30)
grade='C';
else if (student[i] >= max-40)
grade='D';
else
grade='F';
System.out.println("Student "+i+" score is "+student[i]+"and Score is "+grade);
}
}
}
ANSWER 7:
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);
...
...