Friday, December 21, 2018

...Lab10...

Assalamu'alaikum and hello


I'm going to share about the assignment that has given (Lab10) on topic array. We are required to define, declare and show the process of array. Here I include all of the tasks that I have done. 

Question 1











































Question 2











































Question 3


















































That’s all from me. Remain positive though it is impossible. Have a nice day ^_^



Nurazreen binti Mohd Nor (182433)

SSK3100 (Group 15)




Next blog : kychoong.blogspot.com (Choong Kar Yee)

...Lab9...

Assalamu'alaikum and hello..


I'm going to share to all of you my Lab 9 on the topic array. From this assignment, I need to declare, initialize and understand the process of single-dimensional array. 


Question 1

     a)      double[ ] value = new double[10];

     b)      value[value.length – 1] = 5.5;

     c)      System.out.println(value[0] + value[1]);

     d)     double sum = 0;

for (int i = 0; i < value.length; i++)
{
sum += value[i];
}

     e)      double min = 0;

for (int i = 0; i < value.length; i++)
{
if ( min > value[i] )
min = value[i];
}

     f)       System.out.println(value[(int)(Math.random() * value.length)] );

     g)      double[ ] value = {3.5, 5.5, 4.2, 5.6};


Question 2
Line 5: Declaration is wrong, double[100]  should be double[ ] . The array needs to be create before use it, e.g new double[100] .
Line 7: r.length() should be r.length
Line 9: r(i) should be r[i]

Line 9: Math.random should be Math.random()

Question 3 
Write a program that reads in n integers and sort them in increasing order.




Question 4
Write a program that randomly generates n integers between 0 and 10 and counts the occurrence
of each.



Question 5
Write a program that reads an unspecified number of scores and determines how many scores are
above or equal to the average, and how many scores are below the average. Enter a negative
number to signify the end of the input. Assume maximum score is 100.






Question 6
Write two overloaded methods that return the average of an array with the following headers:
public static int average(int[] array)
public static double average(double[] array)
Write a test program that prompts the user to enter 10 double values, invokes this method, then
displays the average value.





Question 7
Write a method that finds the largest element in an array of double values using the following header:
public static double max(double[] array)
Write a test program that prompts the user to enter ten numbers, invokes this method to return the maximum value, and displays the maximum value.





Question 8
Write a program that prompts the user to enter the number of students, the students’ names, and their scores and prints student names in decreasing order of their scores. Assume the name is a string without spaces, use the Scanner’s next() method to read a name.





That’s all from me. Remain positive though it is impossible. Have a nice day ^_^



Nurazreen binti Mohd Nor (182433)

SSK3100 (Group 15)




Next blog : kychoong.blogspot.com (Choong Kar Yee)

...Lab8...

Assalamu'alaikum and hello


I'm going to share about the assignment that has given (Lab8). We are required to define and invoke various types of methods. Here I include all of the tasks that I have done. 


Write a program that assign grades to students in a course. The program prompts the user to input all first and second tests, laboratory works and final exam marks and print out the grade for each of the student. Write the method assignGrade() that receives the mark of a student and display the grade based on the mark.





















































Write a program that has the following methods to:

     a. count the number of letters in a string using the following header:
                  public static int countLetters(String s)

















     b. find the number of occurences of a specified character in a string using the following header:

                  public static int countCharacter(String str, char a


























That’s all from me. Remain positive though it is impossible. Have a nice day ^_^



Nurazreen binti Mohd Nor (182433)

SSK3100 (Group 15)




Next blog : kychoong.blogspot.com (Choong Kar Yee)

...Lab10...

Assalamu'alaikum and hello I'm going to share about the assignment that has given (Lab10) on topic array. We are required to def...