AllBestEssays.com - All Best Essays, Term Papers and Book Report
Search

Programming Exam Answers

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

Essay Preview: Programming Exam Answers

Report this essay
Page 1 of 8

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:

  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);

Answer 4:

 

  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.

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);

...

...

Download as:   txt (4.7 Kb)   pdf (179.4 Kb)   docx (12.3 Kb)  
Continue for 7 more pages »
Only available on AllBestEssays.com