CSE111 – Solved

$ 20.99
Category:

Description

Department of Computer Science and Engineering
CSE110 (Programming Language-I )
Lab 8

Objective

So far in these labs, we have learned how to write programs that involve conditionals and iterations. Towards the very beginning of the semester, we looked at variables and how they store values we need for calculations. This week, we will look at a special kind of variable – one that lets us store and access several values under the same name. These types of variables are called arrays. In today’s lab, we will learn more about arrays and then write a few programs using arrays.

Exercise Set A

Task 1:

(a) Change the following System.out.println() to a System.out.printf() method so that the output is
5.984807753012208

double z;
z = 5+ Math.sin(80*Math.PI/180); System.out.println(z);

(b) Change the following System.out.println() to a System.out.printf() method so that the output is
5.9848 instead of 5.984807753012208

double z;
z = 5+ Math.sin(80*Math.PI/180); System.out.println(z);

Read from the following link and try to use printf () for all variable types you know http://web.cerritos.edu/jwilson/SitePages/java_language_resources/Java_printf_method_quick_reference.pdf

Task 3:
Write a java program that reads 10 numbers from the user, and then prints them in the reverse order.

Task 4:
Write a java program that reads 20 numbers from the user, and then prints only the even numbers in reverse order.

Task 5:
Write a java program that reads 10 numbers from the user. Then read another number from the user, and print “yes” if this number exists among the first 10. Print “no” otherwise.

Task 6:
Write a java program that reads 15 numbers from the user, all the numbers within the range 0-9. Then print the number of times each number has been entered by the user.

Task 7:
CSE111 Lab02 Question1 – Page 1 of 2

Write a java program that reads 10 numbers from the user. After reading each number, print all the numbers that have been entered so far.

Task 8:
Write a java program that reads 10 numbers from the user, but does not allow the user to enter duplicates. This means that if a number has been entered already, the program will not accept it as input again and instead ask the user to enter a different number.

Task 9:
Write a java program that reads 10 numbers from the user. Write the program in such a way so that if the user enters 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, then the output should be 1, 3, 5, 7, 9, 2, 4, 6, 8, 10.
If the user enters 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, then the output should be 10, 30, 50, 70, 90, 20, 40, 60, 80, 100.
If the user enters 2, 5, 6, 9, 12, 13, 14, 15, 16, 17 then the output should be 2, 6, 12, 14, 16, 5, 9, 13, 15, 17.

CSE111 Lab02 Question1 – Page 2 of 2

Reviews

There are no reviews yet.

Be the first to review “CSE111 – Solved”

Your email address will not be published. Required fields are marked *