Professional Documents
Culture Documents
LAB # 1
OBJECTIVE
Question:
Write a java program that reads a number in inches, converts it to meters.
Source Code:
package task1.lab.pkg1;
import java.util.Scanner;
/**
*
* @author Sarah Gohar
*/
public class Task1Lab1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
package task1.lab.pkg1;
import java.util.Scanner;
/**
*
* @author Sarah Gohar
*/
public class Task1Lab1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Please enter inches:");
double inches=sc.nextDouble();
double mtrs=inches*0.0254;
System.out.println("\n'<<<<<Inches are converted into meters>>>>>>>'");
System.out.println("\n'Your converted merters are':");
System.out.println(mtrs);
}
Output:
Question #2
Write a java program to convert days into number of moths and days
Source code:
//program to convert days into number of moths and days
package lab1;
/**
*
* @author Sarah Gohar
*/
public class Lab1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int num = 73;
}
Output:
Question #3
Write a java program to compute body mass index (BMI)
Source code:
// program to compute body mass index (BMI)
package task.pkg3;
import java.util.Scanner;
package task.pkg3;
4 ROLL NO: 2020F-BSE-011
Object Oriented Programming Lab# 01
/**
*
* @author Sarah Gohar
*/
public class Task3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.print("\t***Program to compute body mass index (BMI)***");
Scanner input = new Scanner(System.in);
Output: