Assignment 1
Assignment 1
LAB # 1
INTRODUCTION TO OOP
OBJECTIVE:
To understand OOP(Java Environment),Data Types and Mixed Arthematic
Expression.
LAB TASK
Example:
Test Data
Input a value for inch: 1000.
Expected Output:
1000.0 inch is 25.4 meters.
CODE:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package q1;
/**
*
* @author Karan kumar
*/
import java.util.Scanner;
public class Q1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner number = new Scanner (System.in);
System.out.println("enter value in inches: ");
int num = number.nextInt();
double digit= num*(0.0254);
System.out.println(digit +"meters");
OUTPUT:
2.Write a Java program to convert days into number of months and days.
Example:
Test Data
Input the number of days: 69.
Expected Output:
69 days are 2 months and 9 days.
CODE:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package q2;
/**
*
* @author Karan kumar
*/
import java.util.Scanner;
public class Q2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
OUTPUT:
CODE:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package q3;
/**
*
* @author Karan kumar
*/
import java.util.Scanner;
public class Q3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Input weight in pounds: ");
double weight = input.nextDouble();
OUTPUT: