SlideShare a Scribd company logo
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);
}
}

More Related Content

What's hot

Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
Deyvessh kumar
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
Intro C# Book
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
Ankit Gupta
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
Arunav 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 complexity
Intro 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
 
C programs
C programsC programs
C programs
Vikram Nandini
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
Syed Mustafa
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
raksharao
 
Chapter 3 Arrays in Java
Chapter 3 Arrays in JavaChapter 3 Arrays in Java
Chapter 3 Arrays in Java
Khirulnizam Abd Rahman
 
06.Loops
06.Loops06.Loops
06.Loops
Intro C# Book
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
Khirulnizam Abd Rahman
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
Intro C# Book
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
Intro 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 2015
Moatasim Magdy
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
Upender Upr
 

What's hot (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 to Presentation1 computer shaan

Java file
Java fileJava file
Java file
simarsimmygrewal
 
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
JayveeCultivo
 
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 programs
ADITYA 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
 
Parameters
ParametersParameters
Parameters
James Brotsos
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
KimVeeL
 
Java programs
Java programsJava 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
anupamfootwear
 
C#.net
C#.netC#.net
C#.net
vnboghani
 
Java practical
Java practicalJava practical
Java practical
william otto
 
Java basic Programming.pptx
Java basic Programming.pptxJava basic Programming.pptx
Java basic Programming.pptx
nuevodennis
 
Programs of java
Programs of javaPrograms of java
Programs of java
shafiq sangi
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
university of education,Lahore
 
Programs.pptx
Programs.pptxPrograms.pptx
Programs.pptx
kegeshaddy
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
Infoviaan Technologies
 

Similar to 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
 

Recently uploaded

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 

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); } }