CSE110 – Solved

$ 20.99
Category:

Description

Department of Computer Science and Engineering
Course Code:CSE110 Credits: 1.5
Course Name: Programming Language 1 Semester: FALL’18

Lab 03
Introduction to the Data Types, Variables and Input Output function
And IF ELSE concept in Java
I. Topic Overview:
The students will learn about the different data types in java, and how to create variables of the different data types and use them in their programs. They will also learn variable naming conventions, and try declaring some variable names to see whether or not they are allowed in java. They will conclude with writing and testing a few small programs that take inputs from the user and perform calculations. After that they will learn if else structure in java.

II. Lesson Fit:
Pre-requisite to this lab is Lab1 to Lab2.

III. Learning Outcome:
After this lecture, the students will be able to:
a. Declare variables of different data types
b. Use input and output function
c. Use if else in solving programs.

IV. Anticipated Challenges and Possible Solutions
a. Exercise on variables: The students will make error while naming variables
Solution: Explain the rules again with example
b. Exercise on Java programming: They will make error using input output function and if else structure in java.
Solution: Give them multiple examples with explanation.

V. Acceptance and Evaluation
Students will show their progress as they complete each problem. They will be marked according to their class performance. Their maybe students who might not be able to finish all tasks, they will submit them later and give a viva to get their performance mark.

VI. Activity Detail
a. Hour: 1
Discussion:
Explain different data types and variable declaration
Problem Task: exercise on variables and data types
b. Hour: 2
Discussion:
Explain input-output in java and if else concept
Problem Task: exercise on programming
c. Hour: 3
Discussion:
Details on If else concept in java
Problem Task: exercise on programming and flow chart
VII. Home tasks
a. Unfinished tasks

Lab 3 Activity List
Exercise on variables
Find out which of the followings legal identifiers in Java are, and which are not. Also take note why the invalid ones are invalid. You can try to define each of these (items a to k below) as a variable in Dr. Java’s interaction pane and find out. The first one is done for you as an Example. If you want to define hungry, you have to try int hungry;

a) hungry b) 2AB c) 312.2 d) MOBILE e) “Ans” f) $30
g) Yes/No h) student-id i) A+3 j) ‘X’ k) return

Exercises on data types
Unless otherwise specified, these exercises are to be done in the Dr Java interactions pane as shown in the previous lab.
1. Declare an integer variable. Initialize it with some value of your choice and print it to check the value has been stored properly.
2. Declare and initialize another integer variable. Add this to the first one and print out the result.
Verify that the addition has been done correctly.
3. Repeat exercise 1 and 2 for variables of data type double. Verify your answers.
4. Repeat exercise 1 and 2 for variables of data type String. How does the addition operator work for Strings?

Java programming exercises

Before moving on to the exercises in this section, please read the materials provided in the folder named “How to take input”.

To solve these exercises, you will have to write, save and run complete programs similar to the one we did in the previous lab. Review the last section of that lab if you need help with this step.

1. Write a java program that reads one integer from the user, and prints it back to show which integer was entered by the user.
2. Write a java program that reads two integers from the user, and prints their sum, product and difference.
3. Repeat question 2 for two floating point numbers.
4. Write a java program that reads the radius of a circle and prints its circumference and area.
5. Write a java program that reads two integers from the user and prints “first” if the first number is greater than the second number.
6. Write a java program that reads two integers from the user. Your program should then print “first is greater” if the first number is greater, and “first is not greater” otherwise.
7. Write a java program that reads two integers from the user. Your program should then print “first is greater” if the first number is greater, “second is greater” if the second number is greater, and “the numbers are equal” otherwise.
8. Write a java program that reads two integers, subtracts the smaller number from the larger one, and prints the result.
9. Write a java program that reads an integer, and prints “The number is even” or “The number is odd”, depending on whether the number is even or odd. (Hint: use the modulus operator)

Flowchart exercises

Task 1:
Draw the flowchart of a program that reads an integer, and if the number is even and greater than 10, prints “An even number greater than 10”. If the number is even but lesser than 10, print “An even number not greater than 10”. If the number is greater than 10 but odd, print “An odd number greater than 10”. If the number is odd and also less than 10, print “An odd number less than 10”.

Task 2:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either 2 or 5.
For example, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22 …

Task 3:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either 2 or 5 but not both.
For example, 2, 4, 5, 6, 8, 12, 14, 15, 16, 18, 22 …

Task 4:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of 2 and 5.
For example, 10, 20, 30, 40, 50 …

Task 5:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of NEITHER 2 NOR 5.
For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 …

Task 6:
Draw the flowchart of a program that reads an integer, and prints the integer if it is NOT a multiple of 2 OR NOT a multiple of 5.

Task 7:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out “Pass” if the student got more than 50, and “You shall not pass” otherwise.

Task 8:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out the corresponding grade for that mark. The mark ranges and corresponding grades are shown in the table below.

Marks Grade
90 and above A
80-89 B
70-79 C
60-69 D
50-59 E
Below 50 F

Reviews

There are no reviews yet.

Be the first to review “CSE110 – Solved”

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