Anda di halaman 1dari 17

QUES1:

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 17/01/2017

QUESTION: WAP to display "welcome java" on screen

*/

package basics;

/**

* @author Dell

*/

public class welcome

public static void main(String args[])

System.out.println ("Welcome java");

OUTPUT:
QUES 2:

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 25/01/2016

TOPIC: Keyboard input and operators

QUESTION: Write a java program to take int double and string as input in java
program.

*/

package keyboard_input_and_operators;

import java.util.*;

/**

* @author Dell

*/

public class keyboard_input

public static void main(String args[])

{
System.out.println("Enter your name: ");

Scanner str = new Scanner(System.in);

String abc = str.next();

System.out.println("Enter your roll_no");

Scanner obj=new Scanner(System.in);

int roll=obj.nextInt();

System.out.println("Enter the marks: ");

Scanner i=new Scanner(System.in);

double marks = i.nextDouble();

System.out.println("Name: "+abc+ "\n" + "Roll_number: " +roll+ "\n" +


"Marks: "+marks);

OUTPUT:

QUES 3:

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 25/01/2016
TOPIC: Keyboard input and operators

QUESTION: Convert a temperature from C to F by dividing it by 9/5 and adding 32. Enter
integer value in

variable cel. and convert it to F.

*/

package keyboard_input_and_operators;

import java.util.*;

/**

* @author Dell

*/

public class F_series

public static void main(String args[])

int Fahrenheit;

System.out.println ("Enter the value in celsius: ");

Scanner obj = new Scanner (System.in);

int celsius = obj.nextInt();

System.out.println("Temperature value in celsius : "+celsius);

Fahrenheit = (celsius*9/5)+32;

System.out.println ("Converted value in Fahrenheit: "+Fahrenheit);

OUTPUT:
QUES 4:

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 23/01/2017

TOPIC: Keyboard input and operators

QUESTION: WAP that will display the table of a number

*/

package keyboard_input_and_operators;

import java.util.*;

/**

* @author Dell

*/

public class table

public static void main(String args [])

{
int n,c;

System.out.println ("Enter an integer to print its multiplication table: ");

Scanner in = new Scanner(System.in);

n=in.nextInt();

System.out.println ("Multiplication table of "+n+" is :- ");

for(c=1;c<=10;c++)

System.out.println (n+"*"+c+" = "+(n*c));

OUTPUT:

QUES 5:

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 25/01/2016

TOPIC: Keyboard input and operators


QUESTION: Display first 20 fibonacci series

*/

package keyboard_input_and_operators;

import java.util.*;

/**

* @author Dell

*/

public class fibonacci_series

public static void main(String args[])

int i,no,first=0,second=1,next;

System.out.println ("Enter the number of terms for the fibonacci series: ");

Scanner obj = new Scanner (System.in);

no = obj.nextInt();

System.out.println ("Fibonacci series are: ");

for(i=0;i<no;i++)

System.out.println (first);

next = first + second;

first = second;

second = next;

OUTPUT:
QUES 6:

CODE:

. */

//NAME: SONALI MEHLA

//ROLLNO: 04814002015

//DATE: 15/01/2017

//TOPIC: Control flow Statements

//QUESTION: Write a program consist of variable marks enter value in marks variable
generates grades for

// the user conditions are as follows:

// marks>=80 , <=100, Grade: A+

// 0>marks>100 - invalid en

// marks>=70 <80 -A

// marks>=60 <70 -B

// marks>=50 <60 -C

// marks<50 flunk

*\
import java.util.*;

/**

* @author jims

*/

public class marks

public static void main(String args[])

Scanner obj=new Scanner(System.in);

System.out.println("please enter marks");

int x=obj.nextInt();

if((x<=100) && (x>=80))

System.out.println ("A+");

else if ((x<=80) && (x>70))

System.out.println("A");

else if ((x<=70) && (x>60))

System.out.println("B");

}
else if ((x<=60) && (x>50))

System.out.println("C");

else

System.out.println("Flunk");

OUTPUT:

QUES 7:

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.

*/

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 15/01/2017

TOPIC: Control Flow statements

QUESTION: Write a program to generate the following series.

22

333

4444

55555

666666

7777777

/*

package control_flow_statements;

/**

* @author jims

*/

public class series

{
public static void main (String args[])

int x,y;

for( x=1;x<8;x++)

for( y=1;y<=x;y++)

System.out.print (x);

System.out.println();

OUTPUT:
QUES :

CODE:

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 20/01/2017

TOPIC: Single and multidimensional array

QUESTION:Declare a single dimensional array of integer type enter six distinct integer
values and

calculate average of the same and display

*/

package single_and_multidimensional_array;

import java.util.*;

/**

* @author Dell

*/

public class average

public static void main(String args[])

int n,sum=0;
float average;

System.out.println ("Enter the number you want in the array");

Scanner obj = new Scanner (System.in);

n = obj.nextInt();

int a[]=new int[n];

System.out.println("Enter all the elements");

for(int i=0;i<n;i++)

a[i]=obj.nextInt();

sum = sum + a[i];

System.out.println (sum);

average= sum/n;

System.out.println (average);

OUTPUT:
QUES :

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.

*/

/*

NAME: SONALI MEHLA

ROLLNO: 04814002015

DATE: 20/01/2017

TOPIC: Single and multidimensional array

QUESTION:Generate the following series:

12

345

6789

10 11 12 13 14

15 16 17 18 19 20
*/

package single_and_multidimensional_array;

/**

* @author Dell

*/

public class series

public static void main(String args[])

int b,a,x,var=0;

int arr[][]=new int[6][];

for(x=0;x<6;x++)

arr[x] = new int[x+1];

for(a=0;a<6;a++)

for(b=0;b<a;b++)

arr[a][b]=var;

var++;

}
}

for(a=0;a<6;a++)

for(b=0;b<a;b++)

System.out.print(arr [a][b]+" ");

System.out.println();

OUTPUT:

Anda mungkin juga menyukai