SlideShare a Scribd company logo
1 of 17
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
/* problem 1 : Write a program to find sum for first n numbers.*/
import java.util.Scanner;
class Sum{
public static void main(String args[]){
int sum=0;
System.out.println("input no.");
Scanner ak=new Scanner(System.in);
int n= ak.nextInt();
for(int i=0;i<=n;i++)
{
sum=sum+i;
}
System.out.println("sum: "+sum);
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
/* problem2 : Write a Java Program to find the maximum of n numbers using do-while
loop.*/
import java.util.Scanner;
class Sum{
public static void main(String args[]){
System.out.println("enter the no. you want to insert: ");
Scanner ak= new Scanner(System.in);
int n=ak.nextInt();
int nu[]=new int[n];
int i=0;
do
{
nu[i]=ak.nextInt();
i++;
}while( i<n);
int max=nu[0];
int min=nu[n-1];
i=0;
int j;
if (n==0){
j=i;
max=nu[i];
}
else
{
do
{
j=n-1;
do{
if(nu[i]>nu[j])
max=nu[i];
else
max= nu[j];
j--;
}while(j>i);
i++;
}while(i<n);}
System.out.println(max);
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
/* problem3: .Write a JAVA program to find all Armstrong numbers in the range of 0
and 999*/
class Armstrong{
public static void main( String args[])
{
int i=0;
do{ int n=I,k=0;
if(n>=0||n<=9)
k=1;
if(n>=10||n<=99)
k=2;
if(n>=100||n<=999)
k=3;
int j=n%10; int sum=0;
sum+=Math.pow(j,k);
n=n/10; j=n%10;
sum+=Math.pow(j,k);
n=n/10; j=n%10;
sum+=Math.pow(j,k);
if(sum==i)
System.out.println(sum);
i++;
}while(i<1000)}
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
/* problem4: A common typing error */
import java.util.Scanner;
class Correction
{
public static void main(String args[])
{
String str="";
String s1="qwertyuiop[]asdfghjkl;'zxcvbnm,./ ";
System.out.println("Enter String");
Scanner ak= new Scanner(System.in);
String s4= ak.nextLine();
s4.toUpperCase();
s1.toUpperCase();
for (int i=0;i<s4.length();i++)
{
for(int j=0;j<s1.length();j++)
{
if(s4.charAt(i)==s1.charAt(0)||s4.charAt(i)==s1.charAt(12)||s4.charAt(i)==s1.charAt(2
3)||s4.charAt(i)==s1.charAt(33))
{
str+=s4.charAt(i);
break;
}
if(s4.charAt(i)==s1.charAt(j))
{
str=str+s1.charAt(j-1);
}
}
}
System.out.println(str.toUpperCase());
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
/* problem5: Program of gangster Dawood Abrahim .*/
import java.util.Scanner;
class Daoodstreet{
public static void main(String args[]){
Scanner ak=new Scanner(System.in);
int n=ak.nextInt();
int a[ ]=new int[5000];
for(int i=0;i<n;i++){
a[i]=ak.nextInt();
for(int j=1;j<a[i]+1;j++){
a[j]=ak.nextInt();
}
int m;
int sum=0;
if(a[i]%2==0){
m=a[i]/2;
for(int j=1;j<a[i]+1;j++){
sum+=Math.abs(a[j]-a[m]);
}
}
if(a[i]%2!=0){
m=a[i]/2+1;
for(int j=1;j<a[i]+1;j++){
sum+=Math.abs(a[j]-a[m]);
}
}
System.out.println(sum);
}
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
import java.util.Scanner;
class Cardsontable{
public static void main(String args[]){
double a,sum;
int i;
Scanner ak=new Scanner(System.in);
do{
sum=ak.nextDouble();
a=sum;
i=2;
while(sum>0.00){
sum-=(1.00/i);
i++;
}if (a==0.00)
break;
System.out.println(i-2+" card(s)");
}while(a!=0.00);
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//WEEK PROBLEM -03
import java.util.Scanner;
class Amax
{
public static void main(String args[])
{ int a,i,j,k=0,max=0,min=0,z;
Scanner ak=new Scanner(System.in);
i=ak.nextInt(); j=ak.nextInt();
a=i; int count[]= new int[(j-i+1)];
for(i=i;i<=j;i++){
int n=i;
while(n>1){
if(n%2==0){
count[k]++;
n/=2; }
else{
count[k]++;
n=(n*3)+1;}
}
if(n==1){
count[k]++;
k++; }
}
max=count[k-1];
for(z=1;z<k;z++){
min=count[z-1];
if(max>=min)
max=max;
else
max=min;}
System.out.println(a+" "+" "+j+" "+max);
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Week Problem -04
import java.util.Scanner;
class Exchange
{
public static void main(String args[]){
double sum[],exchange[],a[][];
int z=-1,k=0;
int n[]=new int[1000];
a=new double[1000][1000];
Scanner ak=new Scanner(System.in);
do{
z++;
n[z] =ak.nextInt();
for(int i=0;i<n[z];i++){
a[z][i]=ak.nextDouble();
}
}while(n[z]!=0);
sum=new double[z];
exchange=new double[z];
while(k<z){
for(int i=0;i<n[k];i++){
sum[k]+=a[k][i];
}
sum[k]=(sum[k]/n[k]);
k++;
}
k=0;
while(k<z){
for(int i=0;i<n[k];i++){
if(a[k][i]>sum[k])
exchange[k]+=(a[k][i]-sum[k]);
else
continue;
}
k++;
}
k=0;
while(k<z){
System.out.printf("INR %.2f",exchange[k]);
System.out.println();
k++; }
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
//Week Problem -05
import java.util.Scanner;
class Alien{
public static void main(String args[]){
Scanner ak =new Scanner(System.in);
int n,d,l;
n=ak.nextInt();
d=ak.nextInt();
l=ak.nextInt();
ak.nextLine();
int i=0;
String s1[]=new String[d];
while(d>i)
{
s1[i]=ak.nextLine();
i++;
}
int t=1;
while(l>=t){
String s2[]=new String[n];
int c=0,z=0;
String r="";
String a=ak.nextLine();
String m[]=a.split("");
for(int j=0;j<m.length;j++){
if(z>=n)
break;
if(m[j].equals("("))
{ r="";
c=1;}
else if(m[j].equals(")"))
{c=0;
s2[z]=r;
z++;}
if (c==0&&(!m[j].equals(")"))){
s2[z]=m[j];
z++;}
else
r+=m[j];
}
int count=0;
for(int x=0;x<d;x++){
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.
int p=1;
String w[]=s1[x].split("");
for(i=0;i<n;i++){
if(s2[i].indexOf(w[i])==-1){
p=0;
break;}
}
if(p!=0)
count++;
}
System.out.println("Case #"+t+": "+count);
t++;
}
}
}
//Assignment 2
/*Name-Ankit gupta
Branch-CSE
ROLL NO.-16 */
Thisprogram iswrittenbyAnkitGupta.

More Related Content

What's hot

CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2Voffelarin
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File Harjinder Singh
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creatorsGeorge Bukhanov
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsGlobalLogic Ukraine
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Alexandra N. Martinez
 
Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseAlexandra N. Martinez
 
Scientific calcultor-Java
Scientific calcultor-JavaScientific calcultor-Java
Scientific calcultor-JavaShaibal Ahmed
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 
F# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, HerefordF# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, HerefordKit Eason
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Alexandra N. Martinez
 
Import java
Import javaImport java
Import javaheni2121
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programsMukesh Tekwani
 

What's hot (20)

Insertion Sort Code
Insertion Sort CodeInsertion Sort Code
Insertion Sort Code
 
CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2
 
Main ds manual
Main ds manualMain ds manual
Main ds manual
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
 
123
123123
123
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3
 
Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-case
 
Java programs
Java programsJava programs
Java programs
 
Scientific calcultor-Java
Scientific calcultor-JavaScientific calcultor-Java
Scientific calcultor-Java
 
C# console programms
C# console programmsC# console programms
C# console programms
 
F# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, HerefordF# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, Hereford
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2
 
Import java
Import javaImport java
Import java
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Pattern printing programs
Pattern printing programsPattern printing programs
Pattern printing programs
 
Qprgs
QprgsQprgs
Qprgs
 

Similar to java program assigment -2

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...MaruMengesha
 
1.aimport java.util.Scanner;public class Diamond {   public st.pdf
1.aimport java.util.Scanner;public class Diamond {   public st.pdf1.aimport java.util.Scanner;public class Diamond {   public st.pdf
1.aimport java.util.Scanner;public class Diamond {   public st.pdfaparnatiwari291
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...MaruMengesha
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfankkitextailes
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfAnkitchhabra28
 
java program assigment -1
java program assigment -1java program assigment -1
java program assigment -1Ankit Gupta
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Write a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdfWrite a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdfhadpadrrajeshh
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdfactocomputer
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfanjanacottonmills
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdfapexelectronices01
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjaliSoorej
 

Similar to java program assigment -2 (20)

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
1.aimport java.util.Scanner;public class Diamond {   public st.pdf
1.aimport java.util.Scanner;public class Diamond {   public st.pdf1.aimport java.util.Scanner;public class Diamond {   public st.pdf
1.aimport java.util.Scanner;public class Diamond {   public st.pdf
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
 
java program assigment -1
java program assigment -1java program assigment -1
java program assigment -1
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Write a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdfWrite a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdf
 
Oot practical
Oot practicalOot practical
Oot practical
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
 
programming for Calculator in java
programming for Calculator in javaprogramming for Calculator in java
programming for Calculator in java
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 
LAB1.docx
LAB1.docxLAB1.docx
LAB1.docx
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignment
 

More from Ankit Gupta

Biometricstechnology in iot and machine learning
Biometricstechnology in iot and machine learningBiometricstechnology in iot and machine learning
Biometricstechnology in iot and machine learningAnkit Gupta
 
Week2 cloud computing week2
Week2 cloud computing week2Week2 cloud computing week2
Week2 cloud computing week2Ankit Gupta
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture materialAnkit Gupta
 
Week 4 lecture material cc (1)
Week 4 lecture material cc (1)Week 4 lecture material cc (1)
Week 4 lecture material cc (1)Ankit Gupta
 
Week 3 lecture material cc
Week 3 lecture material ccWeek 3 lecture material cc
Week 3 lecture material ccAnkit Gupta
 
Week 1 lecture material cc
Week 1 lecture material ccWeek 1 lecture material cc
Week 1 lecture material ccAnkit Gupta
 
Mod05lec25(resource mgmt ii)
Mod05lec25(resource mgmt ii)Mod05lec25(resource mgmt ii)
Mod05lec25(resource mgmt ii)Ankit Gupta
 
Mod05lec24(resource mgmt i)
Mod05lec24(resource mgmt i)Mod05lec24(resource mgmt i)
Mod05lec24(resource mgmt i)Ankit Gupta
 
Mod05lec23(map reduce tutorial)
Mod05lec23(map reduce tutorial)Mod05lec23(map reduce tutorial)
Mod05lec23(map reduce tutorial)Ankit Gupta
 
Mod05lec22(cloudonomics tutorial)
Mod05lec22(cloudonomics tutorial)Mod05lec22(cloudonomics tutorial)
Mod05lec22(cloudonomics tutorial)Ankit Gupta
 
Mod05lec21(sla tutorial)
Mod05lec21(sla tutorial)Mod05lec21(sla tutorial)
Mod05lec21(sla tutorial)Ankit Gupta
 
Lecture29 cc-security4
Lecture29 cc-security4Lecture29 cc-security4
Lecture29 cc-security4Ankit Gupta
 
Lecture28 cc-security3
Lecture28 cc-security3Lecture28 cc-security3
Lecture28 cc-security3Ankit Gupta
 
Lecture27 cc-security2
Lecture27 cc-security2Lecture27 cc-security2
Lecture27 cc-security2Ankit Gupta
 
Lecture26 cc-security1
Lecture26 cc-security1Lecture26 cc-security1
Lecture26 cc-security1Ankit Gupta
 
Lecture 30 cloud mktplace
Lecture 30 cloud mktplaceLecture 30 cloud mktplace
Lecture 30 cloud mktplaceAnkit Gupta
 
Week 7 lecture material
Week 7 lecture materialWeek 7 lecture material
Week 7 lecture materialAnkit Gupta
 
Gurukul Cse cbcs-2015-16
Gurukul Cse cbcs-2015-16Gurukul Cse cbcs-2015-16
Gurukul Cse cbcs-2015-16Ankit Gupta
 
Microprocessor full hand made notes
Microprocessor full hand made notesMicroprocessor full hand made notes
Microprocessor full hand made notesAnkit Gupta
 
Transfer Leaning Using Pytorch synopsis Minor project pptx
Transfer Leaning Using Pytorch  synopsis Minor project pptxTransfer Leaning Using Pytorch  synopsis Minor project pptx
Transfer Leaning Using Pytorch synopsis Minor project pptxAnkit Gupta
 

More from Ankit Gupta (20)

Biometricstechnology in iot and machine learning
Biometricstechnology in iot and machine learningBiometricstechnology in iot and machine learning
Biometricstechnology in iot and machine learning
 
Week2 cloud computing week2
Week2 cloud computing week2Week2 cloud computing week2
Week2 cloud computing week2
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture material
 
Week 4 lecture material cc (1)
Week 4 lecture material cc (1)Week 4 lecture material cc (1)
Week 4 lecture material cc (1)
 
Week 3 lecture material cc
Week 3 lecture material ccWeek 3 lecture material cc
Week 3 lecture material cc
 
Week 1 lecture material cc
Week 1 lecture material ccWeek 1 lecture material cc
Week 1 lecture material cc
 
Mod05lec25(resource mgmt ii)
Mod05lec25(resource mgmt ii)Mod05lec25(resource mgmt ii)
Mod05lec25(resource mgmt ii)
 
Mod05lec24(resource mgmt i)
Mod05lec24(resource mgmt i)Mod05lec24(resource mgmt i)
Mod05lec24(resource mgmt i)
 
Mod05lec23(map reduce tutorial)
Mod05lec23(map reduce tutorial)Mod05lec23(map reduce tutorial)
Mod05lec23(map reduce tutorial)
 
Mod05lec22(cloudonomics tutorial)
Mod05lec22(cloudonomics tutorial)Mod05lec22(cloudonomics tutorial)
Mod05lec22(cloudonomics tutorial)
 
Mod05lec21(sla tutorial)
Mod05lec21(sla tutorial)Mod05lec21(sla tutorial)
Mod05lec21(sla tutorial)
 
Lecture29 cc-security4
Lecture29 cc-security4Lecture29 cc-security4
Lecture29 cc-security4
 
Lecture28 cc-security3
Lecture28 cc-security3Lecture28 cc-security3
Lecture28 cc-security3
 
Lecture27 cc-security2
Lecture27 cc-security2Lecture27 cc-security2
Lecture27 cc-security2
 
Lecture26 cc-security1
Lecture26 cc-security1Lecture26 cc-security1
Lecture26 cc-security1
 
Lecture 30 cloud mktplace
Lecture 30 cloud mktplaceLecture 30 cloud mktplace
Lecture 30 cloud mktplace
 
Week 7 lecture material
Week 7 lecture materialWeek 7 lecture material
Week 7 lecture material
 
Gurukul Cse cbcs-2015-16
Gurukul Cse cbcs-2015-16Gurukul Cse cbcs-2015-16
Gurukul Cse cbcs-2015-16
 
Microprocessor full hand made notes
Microprocessor full hand made notesMicroprocessor full hand made notes
Microprocessor full hand made notes
 
Transfer Leaning Using Pytorch synopsis Minor project pptx
Transfer Leaning Using Pytorch  synopsis Minor project pptxTransfer Leaning Using Pytorch  synopsis Minor project pptx
Transfer Leaning Using Pytorch synopsis Minor project pptx
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 

java program assigment -2

  • 1. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. /* problem 1 : Write a program to find sum for first n numbers.*/ import java.util.Scanner; class Sum{ public static void main(String args[]){ int sum=0; System.out.println("input no."); Scanner ak=new Scanner(System.in); int n= ak.nextInt(); for(int i=0;i<=n;i++) { sum=sum+i; } System.out.println("sum: "+sum); } }
  • 2. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. /* problem2 : Write a Java Program to find the maximum of n numbers using do-while loop.*/ import java.util.Scanner; class Sum{ public static void main(String args[]){ System.out.println("enter the no. you want to insert: "); Scanner ak= new Scanner(System.in); int n=ak.nextInt(); int nu[]=new int[n]; int i=0; do { nu[i]=ak.nextInt(); i++; }while( i<n); int max=nu[0]; int min=nu[n-1]; i=0; int j; if (n==0){ j=i; max=nu[i]; } else { do { j=n-1; do{ if(nu[i]>nu[j]) max=nu[i]; else max= nu[j]; j--; }while(j>i); i++; }while(i<n);} System.out.println(max); } }
  • 3. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.
  • 4. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. /* problem3: .Write a JAVA program to find all Armstrong numbers in the range of 0 and 999*/ class Armstrong{ public static void main( String args[]) { int i=0; do{ int n=I,k=0; if(n>=0||n<=9) k=1; if(n>=10||n<=99) k=2; if(n>=100||n<=999) k=3; int j=n%10; int sum=0; sum+=Math.pow(j,k); n=n/10; j=n%10; sum+=Math.pow(j,k); n=n/10; j=n%10; sum+=Math.pow(j,k); if(sum==i) System.out.println(sum); i++; }while(i<1000)} } }
  • 5. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. /* problem4: A common typing error */ import java.util.Scanner; class Correction { public static void main(String args[]) { String str=""; String s1="qwertyuiop[]asdfghjkl;'zxcvbnm,./ "; System.out.println("Enter String"); Scanner ak= new Scanner(System.in); String s4= ak.nextLine(); s4.toUpperCase(); s1.toUpperCase(); for (int i=0;i<s4.length();i++) { for(int j=0;j<s1.length();j++) { if(s4.charAt(i)==s1.charAt(0)||s4.charAt(i)==s1.charAt(12)||s4.charAt(i)==s1.charAt(2 3)||s4.charAt(i)==s1.charAt(33)) { str+=s4.charAt(i); break; } if(s4.charAt(i)==s1.charAt(j)) { str=str+s1.charAt(j-1); } } } System.out.println(str.toUpperCase()); } }
  • 6. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.
  • 7. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. /* problem5: Program of gangster Dawood Abrahim .*/ import java.util.Scanner; class Daoodstreet{ public static void main(String args[]){ Scanner ak=new Scanner(System.in); int n=ak.nextInt(); int a[ ]=new int[5000]; for(int i=0;i<n;i++){ a[i]=ak.nextInt(); for(int j=1;j<a[i]+1;j++){ a[j]=ak.nextInt(); } int m; int sum=0; if(a[i]%2==0){ m=a[i]/2; for(int j=1;j<a[i]+1;j++){ sum+=Math.abs(a[j]-a[m]); } } if(a[i]%2!=0){ m=a[i]/2+1; for(int j=1;j<a[i]+1;j++){ sum+=Math.abs(a[j]-a[m]); } } System.out.println(sum); } } }
  • 8. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.
  • 9. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. import java.util.Scanner; class Cardsontable{ public static void main(String args[]){ double a,sum; int i; Scanner ak=new Scanner(System.in); do{ sum=ak.nextDouble(); a=sum; i=2; while(sum>0.00){ sum-=(1.00/i); i++; }if (a==0.00) break; System.out.println(i-2+" card(s)"); }while(a!=0.00); } }
  • 10. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.
  • 11. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. //WEEK PROBLEM -03 import java.util.Scanner; class Amax { public static void main(String args[]) { int a,i,j,k=0,max=0,min=0,z; Scanner ak=new Scanner(System.in); i=ak.nextInt(); j=ak.nextInt(); a=i; int count[]= new int[(j-i+1)]; for(i=i;i<=j;i++){ int n=i; while(n>1){ if(n%2==0){ count[k]++; n/=2; } else{ count[k]++; n=(n*3)+1;} } if(n==1){ count[k]++; k++; } } max=count[k-1]; for(z=1;z<k;z++){ min=count[z-1]; if(max>=min) max=max; else max=min;} System.out.println(a+" "+" "+j+" "+max); }
  • 12. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.
  • 13. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. //Week Problem -04 import java.util.Scanner; class Exchange { public static void main(String args[]){ double sum[],exchange[],a[][]; int z=-1,k=0; int n[]=new int[1000]; a=new double[1000][1000]; Scanner ak=new Scanner(System.in); do{ z++; n[z] =ak.nextInt(); for(int i=0;i<n[z];i++){ a[z][i]=ak.nextDouble(); } }while(n[z]!=0); sum=new double[z]; exchange=new double[z]; while(k<z){ for(int i=0;i<n[k];i++){ sum[k]+=a[k][i]; } sum[k]=(sum[k]/n[k]); k++; } k=0; while(k<z){ for(int i=0;i<n[k];i++){ if(a[k][i]>sum[k]) exchange[k]+=(a[k][i]-sum[k]); else continue; } k++; } k=0; while(k<z){ System.out.printf("INR %.2f",exchange[k]); System.out.println(); k++; } }
  • 14. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. }
  • 15. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. //Week Problem -05 import java.util.Scanner; class Alien{ public static void main(String args[]){ Scanner ak =new Scanner(System.in); int n,d,l; n=ak.nextInt(); d=ak.nextInt(); l=ak.nextInt(); ak.nextLine(); int i=0; String s1[]=new String[d]; while(d>i) { s1[i]=ak.nextLine(); i++; } int t=1; while(l>=t){ String s2[]=new String[n]; int c=0,z=0; String r=""; String a=ak.nextLine(); String m[]=a.split(""); for(int j=0;j<m.length;j++){ if(z>=n) break; if(m[j].equals("(")) { r=""; c=1;} else if(m[j].equals(")")) {c=0; s2[z]=r; z++;} if (c==0&&(!m[j].equals(")"))){ s2[z]=m[j]; z++;} else r+=m[j]; } int count=0; for(int x=0;x<d;x++){
  • 16. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta. int p=1; String w[]=s1[x].split(""); for(i=0;i<n;i++){ if(s2[i].indexOf(w[i])==-1){ p=0; break;} } if(p!=0) count++; } System.out.println("Case #"+t+": "+count); t++; } } }
  • 17. //Assignment 2 /*Name-Ankit gupta Branch-CSE ROLL NO.-16 */ Thisprogram iswrittenbyAnkitGupta.