Lab Report 01: Course Information
Lab Report 01: Course Information
Lab Report 01
Course Information
Course Title: Object Oriented Programming
Course code: ICE107
Section: 01
Course Instructor: Mohammad Rafsun Islam
Student Information
Name: Rafat Hasan Dipu
ID: 2020-1-50-042
Date: 21-07-2020
Question 01: Write a java program which will take number of days as
an integer value and the program will produce output as the day of the
week after the inputted number of days from the current day. For
example, if the input is 6 and today is Friday, the program will produce
output “The weekday is Thursday”.
Code:
package helloworld;
import java.util.*;
public class Dayprint {
Output:
Question 02: Write a java program that prints all real solutions to the
quadratic equation ax2+bx+c=0.Read in a, b, c and use the quadratic
formula. Quadratic formulas are x1= (-b+√b^2-4ac)/2a
X2= (-b-√b^2-4ac)/2a.
Code:
package helloworld;
import java.util.*;
public class Quadraticequation {
}
Output:
Discussion:
First java program is mainly show weekday. Now I explain that code.
In this program, when you run it, the program need a value. This portion
work based on mainly import java.util.*; . Now I explain main function.
Here we declare a integer type variable called day. Then I show 7 days
name by using print function. Then scanner class is used to get user
input, and it is found in the java.util.*; package. The user input assigned
in day variable. Then I use switch statement and its under 7 cases. When
user input value of “day” variable switch statement evaluates expression
and compares it values of 7 cases label. Now, if the value matches a
certain case label, then all the statements of the matching case label are
executed and break the case. If value do not match any cases then code
go to default and break this.