SlideShare una empresa de Scribd logo
1 de 10
2 . A special two-digit number is such that when the sum of its digits is added to the product of
its digits , the result is equal to original number
Example : 59
5+9 = 14
5*9 = 45
45+14 = 59 Therefore , 59 is a special two digit number
Write a program in java to check whether a number is special two-digit number or not
Ans-
class Prog2
{
static void test(int num)//user inputs a two-digit number
{
int m = num;
int product = 1;
int sum = 0;
while(m>0)
{
int dig = m%10;
sum = sum+dig;
product = product*dig;
m/=10;
}
int finalsum = sum+product;
if(finalsum==num)
System.out.println(num+” is a special two digit number “);
else
System.out.println(num+ ” is not a special two digit number “);
}
}
• 4.Write a program to display the following pattern :
1 3 5 7 9
3 5 7 9 1
5 7 8 1 3
7 9 1 3 5
9 1 3 5 7
Ans-
• class Program4
{
static void teja()
{
• for(int i = 1,l=1;i<=5;i++,l+=2)
{
int k = 1;
• for(int j = 1,m=l;j<=5;j++,m+=2)
{
if(m>9)
{
System.out.print(k+” “);
k+=2;
}
else
if(l==5&&m==9)
{
System.out.print(“8 “);
}
else
System.out.print(m+” “);
}
System.out.println();
}
}
}
• 5.Write a Program in java to obtain the first eight
numbers of the following series :
1,11,111,1111………………
class Prog5
{
static void test()
{
double s=0.0;
int p;
for(int i = 0;i<=7;i++)
{
s=s+Math.pow(10,i);
p = (int)s;
System.out.print(p+” , “);
}
}
}
• Star Pyramid(Nested Loops)
public class vfg
{ public static void main(String args[])
{
int b=4;
for(int i=1;i<=9;i=i+2)
{ for(int j=1;j<=b;j++)
{ System.out.print(" ");
}
for(int k=1;k<=i;k++)
{ System.out.print("*");
}
System.out.println();
b--;
}
}
}
• Sum Of Double Dimensional Array Diagonals
• import java.io.*;
public class sumofdiagonals
{ public static void main(String args[]) throws IOException
{ InputStreamReader read = new
InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
int arr[][] = {{6,9,0,8},{3,2,1,5},{2,9,0,1},{4,1,9,6}};
int sum=0;
for(int i=0;i<4;i++)
{ for(int j=0;j<4;j++)
{ if(i==j)
sum+=arr[i][j];
}
}
System.out.println(sum);
}
}
• Arrange Names From Array Alphabetically
• import java.io.*;
public class namearranger
{ public static void main(String args[]) throws IOException
{ InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
String arr[] = new String[5];
System.out.println("Enter 5 names.");
for(int i=0;i<5;i++)
{ arr[i]=br.readLine();
}
String temp=null;
System.out.println("They will now be arranged alphabetically");
for(int i=0;i<5;i++)
{ for(int j=0;j<4;j++)
{ if((int)arr[j].charAt(0) > (int)arr[j+1].charAt(0))
{ temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(int i=0;i<5;i++)
{ System.out.println(arr[i]);
}
}
}
• 2 - 4 + 6 - 8......20
• import java.io.*;
public class twominusfourplussixminuseight
{
public static void main(String args[])
{ System.out.println("2-4+6-8...-20");
int a=1;
int s=0;
for(int i=2;i<=20;i+=2)
{
if(a%2!=0)
s+=i;
else
s-=i;
a++;
System.out.println(a+ " " +i+ " " +s);
}
System.out.println(s);
}
}
• Count Positive & Negative Numbers In List
• import java.io.*;
public class countposneg
{ public static void main(String args[]) throws IOException
{ InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
int arr[] = new int[575];
int j=2;
System.out.println("Enter a list of numbers(terminates on entering 0)");
for(int i=0;j<3;i++)
{ arr[i] = Integer.parseInt(br.readLine());
if(arr[i]==0)
{j++; }
}
int neg=0, poseve=0, posodd=0;
for(int i=0;i
{ if(arr[i]<0)
{neg++;}
if(arr[i]>0 && arr[i]%2==0)
{poseve++;}
if(arr[i]>0 && arr[i]%2==1)
{posodd++;}
}
System.out.println("nnNumber Of Negative Numbers: "+neg);
System.out.println("Number Of Positive Even Numbers: "+poseve);
System.out.println("Number of Positive Odd Numbers: "+posodd);
}
}
• Pattern 1 :
• 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
• Java Program :
• public class MainClass
• {
• public static void main(String[] args)
• {
• Scanner sc = new Scanner(System.in);
•
• //Taking rows value from the user
•
• System.out.println("How many rows you want in this pattern?");
•
• int rows = sc.nextInt();
•
• System.out.println("Here is your pattern....!!!");
•
• for (int i = 1; i <= rows; i++)
• {
• for (int j = 1; j <= i; j++)
• {
• System.out.print(j+" ");
• }
•
• System.out.println();
• }}}}
A Program to calculate charges for sending particles when the charges are as
follows
For the first 1KG Rs.15.00 , For additional weight , for every 500gm or
fraction thereof: Rs 8.00
class Prog1
{
static void test(double wt)//user enters the weight in KGs
{
System.out.println(“Parcel Weight is “+wt);
int icharge = 15;
System.out.println(“Initial charge is “+icharge);
int rwt = (int)((wt-1)*1000);
System.out.println(“Remaining weight after deducing 1Kg “+rwt);
int rcharge = (rwt/500)*8;
System.out.println(“Charge excluding fractional part is
Rs.”+(icharge+rcharge));
int fcharge = (rwt%500>0)?8:0;
System.out.println(“Charge for fractional part is Rs. “+fcharge);
int tcharge = icharge+rcharge+fcharge;
System.out.println(“Total Charge is Rs. “+tcharge);
}
}

Más contenido relacionado

La actualidad más candente

Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project FileDeyvessh kumar
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2Ankit Gupta
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload lastArunav Ray
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexityIntro C# Book
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manualSyed Mustafa
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contdraksharao
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and MapsIntro C# Book
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queuesIntro C# Book
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Moatasim Magdy
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 

La actualidad más candente (20)

Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
 
C program
C programC program
C program
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
Ds lab handouts
Ds lab handoutsDs lab handouts
Ds lab handouts
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
C programs
C programsC programs
C programs
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
 
Chapter 3 Arrays in Java
Chapter 3 Arrays in JavaChapter 3 Arrays in Java
Chapter 3 Arrays in Java
 
06.Loops
06.Loops06.Loops
06.Loops
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 

Similar a Presentation1 computer shaan

Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJayveeCultivo
 
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
 
Computer java programs
Computer java programsComputer java programs
Computer java programsADITYA BHARTI
 
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
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)Chhom Karath
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...Hiraniahmad
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdfanupamfootwear
 
Java basic Programming.pptx
Java basic Programming.pptxJava basic Programming.pptx
Java basic Programming.pptxnuevodennis
 

Similar a Presentation1 computer shaan (20)

Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdf
 
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-...
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
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-...
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...
 
Parameters
ParametersParameters
Parameters
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
Java programs
Java programsJava programs
Java programs
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 
C#.net
C#.netC#.net
C#.net
 
Java practical
Java practicalJava practical
Java practical
 
Java basic Programming.pptx
Java basic Programming.pptxJava basic Programming.pptx
Java basic Programming.pptx
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
 
Programs.pptx
Programs.pptxPrograms.pptx
Programs.pptx
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
 

Último

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 

Último (20)

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 

Presentation1 computer shaan

  • 1. 2 . A special two-digit number is such that when the sum of its digits is added to the product of its digits , the result is equal to original number Example : 59 5+9 = 14 5*9 = 45 45+14 = 59 Therefore , 59 is a special two digit number Write a program in java to check whether a number is special two-digit number or not Ans- class Prog2 { static void test(int num)//user inputs a two-digit number { int m = num; int product = 1; int sum = 0; while(m>0) { int dig = m%10; sum = sum+dig; product = product*dig; m/=10; } int finalsum = sum+product; if(finalsum==num) System.out.println(num+” is a special two digit number “); else System.out.println(num+ ” is not a special two digit number “); } }
  • 2. • 4.Write a program to display the following pattern : 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7 Ans- • class Program4 { static void teja() { • for(int i = 1,l=1;i<=5;i++,l+=2) { int k = 1; • for(int j = 1,m=l;j<=5;j++,m+=2) { if(m>9) { System.out.print(k+” “); k+=2; } else if(l==5&&m==9) { System.out.print(“8 “); } else System.out.print(m+” “); } System.out.println(); } } }
  • 3. • 5.Write a Program in java to obtain the first eight numbers of the following series : 1,11,111,1111……………… class Prog5 { static void test() { double s=0.0; int p; for(int i = 0;i<=7;i++) { s=s+Math.pow(10,i); p = (int)s; System.out.print(p+” , “); } } }
  • 4. • Star Pyramid(Nested Loops) public class vfg { public static void main(String args[]) { int b=4; for(int i=1;i<=9;i=i+2) { for(int j=1;j<=b;j++) { System.out.print(" "); } for(int k=1;k<=i;k++) { System.out.print("*"); } System.out.println(); b--; } } }
  • 5. • Sum Of Double Dimensional Array Diagonals • import java.io.*; public class sumofdiagonals { public static void main(String args[]) throws IOException { InputStreamReader read = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(read); int arr[][] = {{6,9,0,8},{3,2,1,5},{2,9,0,1},{4,1,9,6}}; int sum=0; for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { if(i==j) sum+=arr[i][j]; } } System.out.println(sum); } }
  • 6. • Arrange Names From Array Alphabetically • import java.io.*; public class namearranger { public static void main(String args[]) throws IOException { InputStreamReader read = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(read); String arr[] = new String[5]; System.out.println("Enter 5 names."); for(int i=0;i<5;i++) { arr[i]=br.readLine(); } String temp=null; System.out.println("They will now be arranged alphabetically"); for(int i=0;i<5;i++) { for(int j=0;j<4;j++) { if((int)arr[j].charAt(0) > (int)arr[j+1].charAt(0)) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } for(int i=0;i<5;i++) { System.out.println(arr[i]); } } }
  • 7. • 2 - 4 + 6 - 8......20 • import java.io.*; public class twominusfourplussixminuseight { public static void main(String args[]) { System.out.println("2-4+6-8...-20"); int a=1; int s=0; for(int i=2;i<=20;i+=2) { if(a%2!=0) s+=i; else s-=i; a++; System.out.println(a+ " " +i+ " " +s); } System.out.println(s); } }
  • 8. • Count Positive & Negative Numbers In List • import java.io.*; public class countposneg { public static void main(String args[]) throws IOException { InputStreamReader read = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(read); int arr[] = new int[575]; int j=2; System.out.println("Enter a list of numbers(terminates on entering 0)"); for(int i=0;j<3;i++) { arr[i] = Integer.parseInt(br.readLine()); if(arr[i]==0) {j++; } } int neg=0, poseve=0, posodd=0; for(int i=0;i { if(arr[i]<0) {neg++;} if(arr[i]>0 && arr[i]%2==0) {poseve++;} if(arr[i]>0 && arr[i]%2==1) {posodd++;} } System.out.println("nnNumber Of Negative Numbers: "+neg); System.out.println("Number Of Positive Even Numbers: "+poseve); System.out.println("Number of Positive Odd Numbers: "+posodd); } }
  • 9. • Pattern 1 : • 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 • Java Program : • public class MainClass • { • public static void main(String[] args) • { • Scanner sc = new Scanner(System.in); • • //Taking rows value from the user • • System.out.println("How many rows you want in this pattern?"); • • int rows = sc.nextInt(); • • System.out.println("Here is your pattern....!!!"); • • for (int i = 1; i <= rows; i++) • { • for (int j = 1; j <= i; j++) • { • System.out.print(j+" "); • } • • System.out.println(); • }}}}
  • 10. A Program to calculate charges for sending particles when the charges are as follows For the first 1KG Rs.15.00 , For additional weight , for every 500gm or fraction thereof: Rs 8.00 class Prog1 { static void test(double wt)//user enters the weight in KGs { System.out.println(“Parcel Weight is “+wt); int icharge = 15; System.out.println(“Initial charge is “+icharge); int rwt = (int)((wt-1)*1000); System.out.println(“Remaining weight after deducing 1Kg “+rwt); int rcharge = (rwt/500)*8; System.out.println(“Charge excluding fractional part is Rs.”+(icharge+rcharge)); int fcharge = (rwt%500>0)?8:0; System.out.println(“Charge for fractional part is Rs. “+fcharge); int tcharge = icharge+rcharge+fcharge; System.out.println(“Total Charge is Rs. “+tcharge); } }