Professional Documents
Culture Documents
Test 1: Java: Name Rohit Kumar Roll No. 1802452 CEC CGC Landran
Test 1: Java: Name Rohit Kumar Roll No. 1802452 CEC CGC Landran
Test 1: Java: Name Rohit Kumar Roll No. 1802452 CEC CGC Landran
import java.util.Scanner;
//1
/* int total=0;
int phy=sc.nextInt();
int math=sc.nextInt();
int s_sci=sc.nextInt();
int eng=sc.nextInt();
int hind=sc.nextInt();
total=(phy+math+s_sci+eng+hind)/5;
*/
//2
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=a+b+c;
*/
//3
String s=sc.nextLine();
*/
//4
int m=a*1000;
//5
if(sc.hasNextInt()){
else if(sc.hasNext()){
if(string.length()>1){
else{
}}*/
//6
/* float a=7/4*9/2 ;
System.out.println(a);
*/
//7
/* char a='b';
a=(char)(a+8);
System.out.println(a);
a=(char)(a-8);
System.out.println(a);*/
//8
int a=sc.nextInt();
int b=10;
if(a>b){
else{
}*/
//9
int v=sc.nextInt();
int u=sc.nextInt();
int a=sc.nextInt();
int s=sc.nextInt();
float total=((v*v)-(u*u))/2*a*s;
System.out.println("(v^2-u^2)/2as= "+total);*/
//10
/* int x=7;
int a=7*49/7+35/7;
System.out.println(a);
//11
*/
String s=sc.nextLine();
String s1=s.toLowerCase();
System.out.println(s1);*/
//12
String s=sc.nextLine();
System.out.println(s1);
*/
//13
System.out.println(letter);
String s1=letter.replace("<|name|>","suraj");
System.out.println(s1);*/
//14
String s=sc.nextLine();
System.out.println(s.indexOf(" "));
System.out.println(s.indexOf(" "));*/
//15
System.out.println(letter);*/
// 16
float a=sc.nextFloat();
float b=sc.nextFloat();
float c=sc.nextFloat();
float total=(a+b+c)/3;
if(total>=40) {
System.out.println("you r pass");
else{
System.out.println("you r fail");
else{
System.out.println("you r fail");
*/
// 18.Write a Java program to find whether a year entered by the user is a leap year or not.
int year=sc.nextInt();
System.out.println("leap year");
else{
*/
// 19
/* int a=sc.nextInt();
for(int i=a;i>0;i--){
for(int j=0;j<i;j++){
System.out.print("*");
System.out.println();
}*/
//20
for(int i=1;i<=10;i++){
sum+=a*i;
System.out.println(sum);*/
/* float []a={2.5f,1.5f,3.5f,4.5f,6.5f};
float sum=0;
for(float b:a){
sum=sum+b;
System.out.println(sum);*/
// 22.Write a program to find out whether a given integer is present in an array or not.
/* int a[]={1,2,3,4,5,6};
int b=sc.nextInt();
boolean c=false;
for(int i=0;i<a.length;i++){
if (b==a[i]){
c=true;
break;
}}
if(c){
System.out.println("present");}
else{
}*/
}
System.out.println();
}*/
// 26 and both are same 27.Write a Java program to find the maximum element in a Java array.
/* int a[]={3,5,7,9,11};
int max=a[0];
for(int i=1;i<a.length;i++){
if(max<a[i]){
max=a[i];
System.out.println(max);*/
/* int a[]={2,1,4,3,5};
for(int i=0;i<a.length-1;i++){
if(a[i]>a[i+1]){
a[i]=a[i+1];
a[i+1]=temp;
}}
for(int i=0;i<a.length;i++) {
System.out.println(a[i]);
*///29and both are same 25.Write a Java program to print the elements of an array in reverse order.
/* int a[]={1,2,3,45,5};
for(int i=a.length-1;i>=0;i--){
System.out.println(a[i]);
}*/
// 30.What can be done using one type of loop can also be done using the other two types of
loops - True or False.
//answer=True
//17
/*
float tax = 0;
if(income<=2.5){
tax = tax + 0;
else if(income>10.0f){
}}
23 answer *************
import java.util.Scanner;
class Main
{
int i;
int n=sc.nextInt();
double avg=0;
System.out.println("Enter marks");
for( i=0;i<n;i++)
a[i]=sc.nextInt();
for( i=0;i<n;i++)
avg=avg+a[i];
System.out.print("Average of (");
for(i=0;i<n-1;i++)
System.out.print(a[i]+",");
}
System.out.println(a[i]+") ="+avg/n);