[go: up one dir, main page]

0% found this document useful (0 votes)
2 views5 pages

Omoops 1

The document outlines an experiment focused on various methods of accepting user input in Java, including command line arguments and the Scanner class. It demonstrates arithmetic operations, the Fibonacci series, reversing a four-digit number, and the use of right shift and unsigned right shift operators. Students are expected to document their learning experiences, challenges faced, and provide examples to support their understanding of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Omoops 1

The document outlines an experiment focused on various methods of accepting user input in Java, including command line arguments and the Scanner class. It demonstrates arithmetic operations, the Fibonacci series, reversing a four-digit number, and the use of right shift and unsigned right shift operators. Students are expected to document their learning experiences, challenges faced, and provide examples to support their understanding of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment:1

Program on Various ways to accept data through keyboard and unsigned right shift operator
Input through Command Line Argument
To demonstrate the concept of arithmetic operators.
List the subjects offered to you in sem III
Input through scanner Class
Print the Fibonacci series upto the nth term taking the value of n from the user.
WAP to reverse the four digit no.
Unsigned right shift operator
Demonstrate the working of right shift operator.
OBJECTIVE : To make students understand how to take input from the user and explain the difference
in working of right shift operator and unsigned right shift operator.
DESCRIPTION : Students should write about the following along with examples to support the theory
Command-Line Arguments
Scanner class
Bitwise operators in java and C
CONCLUSION: Students are expected to List the error they are facing along with their solution
REFERENCES :
Practical no:1 public class Main {
public static void main(String[] args) {
float x = 6; float y = 3; float z = 2;
System.out.println("Addition:"+(x + y+z));
System.out.println("Subtraction:"+(x-y-z));
System.out.println("Multiplication:"+x*y*z);
System.out.println("Division:"+x/y/z);
System.out.println("Modulous:"+x%y);
System.out.println("Increament:"+(++x));
System.out.println("Decreament:"+(--y));
}
}

Output:
Addition:11.0
Subtraction:1.0
Multiplication:36.0
Division:1.0
Modulous:0.0
Increament:7.0
Decreament:2.0

2.List of subject: public class Main{


public static void main(String[] args){
System.out.println("Math-3");
System.out.println("Dsgt");
System.out.println("DLCA");
System.out.println("DS");
System.out.println("CG");
System.out.println("OOPM");
}
}

Output:
Math-3
Dsgt
DLCA
DS
CG
OOPM

Input through Scanner Class: import

java.util.Scanner;

public class FibonacciSeries {


public static void main(String[] args) {

System.out.println(“Om Gaikwad”);
Scanner scanner = new Scanner(System.in);

System.out.print("Enter the value of n: ");

int n = scanner.nextInt(); int t1 = 0, t2 = 1;

System.out.print("Fibonacci series upto " + n + " terms: ");

for (int i = 1; i <= n; i++) {

System.out.print(t1 + " ");

int sum = t1 + t2; t1 = t2;

t2 = sum;

System.out.println();

Output:

WAP to reverse the four digit no.:

import java.util.Scanner; public class

ReverseNumber { public static void

main(String[] args) {

System.out.println(“Om Gaikwad”);

Scanner scanner = new Scanner(System.in);

System.out.print("Enter a four-digit number: ");


int num = scanner.nextInt();

int reversed = 0; while (num != 0) {


int digit = num % 10; reversed =

reversed * 10 + digit; num /= 10;

System.out.println("Reversed number: " + reversed);

Output:

Unsigned right shift operator:

import java.util.Scanner;

public class UnsignedRightShift {

public static void main(String[] args) {

System.out.println(“Om Gaikwad”);

Scanner scanner = new Scanner(System.in);

System.out.print("Enter a number: "); int

num = scanner.nextInt();

System.out.println("Unsigned right shift of " + num + " by 1 bit: " + (num >>> 1));

System.out.println("Unsigned right shift of " + num + " by 2 bits: " + (num >>> 2));

System.out.println("Unsigned right shift of " + num + " by 3 bits: " + (num >>> 3)); }

Output:

You might also like