0% found this document useful (0 votes)
7 views13 pages

Java Programs for Basic Input Tasks

The document contains multiple Java programs that demonstrate various functionalities such as finding the largest and smallest of two or three numbers, checking voter eligibility based on age, identifying vowels and consonants, determining leap years, and generating electricity bills based on customer readings. Each program uses the Scanner class for input and includes conditional statements to produce the desired output. The code examples also contain some typographical errors and inconsistencies in variable names and logic.

Uploaded by

akulaakhil234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Java Programs for Basic Input Tasks

The document contains multiple Java programs that demonstrate various functionalities such as finding the largest and smallest of two or three numbers, checking voter eligibility based on age, identifying vowels and consonants, determining leap years, and generating electricity bills based on customer readings. Each program uses the Scanner class for input and includes conditional statements to produce the desired output. The code examples also contain some typographical errors and inconsistencies in variable names and logic.

Uploaded by

akulaakhil234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

class Oth
{
public static void main(String[] args)
{
int x,y,z;
Scanner p=new Scanner([Link]);
[Link]("Enetr x value:");
x=[Link]();
[Link]("Enetr y value:");
y=[Link]();
z=(x>y)?x:y;
[Link]("Display large value:"+z);
}
}
import [Link];

class Oth
{
public static void main(String[] args)
{
int x,y,z;
Scanner p=new Scanner([Link]);
[Link]("Enetr x value:");
x=[Link]();
[Link]("Enetr y value:");
y=[Link]();
if(x>y)
{
[Link]("Display large value is x:"+x);
}
else
{
[Link]("Display large value is y:"+y);
}
}
}
import [Link];

class Oth
{
public static void main(String[] args)
{
int x,y,z;
Scanner p=new Scanner([Link]);
[Link]("Enetr x value:");
x=[Link]();
[Link]("Enetr y value:");
y=[Link]();
if(x<y)
{
[Link]("Display samll value is x:"+x);
}
else
{
[Link]("Display samll value is y:"+y);
}
}
}
// Eligible for vote or not
import [Link];

class Oth
{
public static void main(String[] args)
{
int age;
Scanner p=new Scanner([Link]);
[Link]("Enter your age:");
age=[Link]();
if(age>=18)
{
[Link]("Eligible for vote..");
}
else
{
[Link]("Not eligible for vote and wait for "+(18-age)+" for years");
}

}
}
// Vowels or Consonents
import [Link];

class Oth
{
public static void main(String[] args) throws Exception
{
char c;
[Link]("Enter a character:");
c = (char)[Link]();

if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
{
[Link]("Vowels...");
}
else
{
[Link]("Consonents ...");
}

}
}
// largest of three numbers
import [Link];

class Oth
{
public static void main(String[] args)
{
int x,y,z;
Scanner p=new Scanner([Link]);
[Link]("Enetr x value:");
x=[Link]();
[Link]("Enetr y value:");
y=[Link]();
[Link]("Enetr z value:");
z=[Link]();
if((x>y)&&(x>y))
{
[Link]("Display large value is x:"+x);
}
else if((y>x)&&(y>z))
{
[Link]("Display large value is y:"+y);
}
else
{
[Link]("Display large value is z:"+z);
}
}
}
// smallest of three numbers
import [Link];
class Oth
{
public static void main(String[] args)
{
int x,y,z;
Scanner p=new Scanner([Link]);
[Link]("Enetr x value:");
x=[Link]();
[Link]("Enetr y value:");
y=[Link]();
[Link]("Enetr z value:");
z=[Link]();
if((x<y)&&(x<y))
{
[Link]("Display small value is x:"+x);
}
else if((y<x)&&(y<z))
{
[Link]("Display small value is y:"+y);
}
else
{
[Link]("Display small value is z:"+z);
}
}
}
import [Link]; // Enter year leap year or not
class Leap
{
public static void main(String[] args)
{ int year;
Scanner p=new Scanner([Link]);
[Link]("Enter any year:");
year=[Link]();
if(year%400==0)
{
[Link]("Leap year");
}
else if(year%100==0)
{
[Link]("Non leap year");
}
else if(year%4==0)
{
[Link]("Leap year");
}
else
{
[Link]("Non leap year");
}}}
// Current bill genarate
import [Link];

class Curr
{
public static void main(String[] args)
{
String cname,add;
int pred,lred,mno,sno,price,cunt;
Scanner p=new Scanner([Link]);
[Link]("Enter Customer Name :");
cname=[Link]();
[Link]("Enter Customer Address:");
add=[Link]();
[Link]("Enter Customer No :");
sno=[Link]();
[Link]("Enter Meater No :");
mno=[Link]();
[Link]("Enter Previous reading :");
lred=[Link]();
[Link]("Enter present reading :");
pred=[Link]();
cunt=pred-lred;
[Link]("Customer id : "+sno);
[Link]("Meater No : "+mno);
[Link]("Customer Name : "+cname);
[Link]("Customer Address : "+add);
[Link]("Present Reading : "+pred);
[Link]("Last Reading : "+lred);
[Link]("Total units : "+cunt);

if(cunt>=700)
{
price=cunt*5;
[Link]("Pay amount : "+price);
}
else if(cunt>=500 && cunt<700)
{
price=cunt*4;
[Link]("Pay amount : "+price);
}
else if(cunt>=300 && cunt<500)
{
price=cunt*3;
[Link]("Pay amount : "+price);
}
else if(cunt>=200 && cunt<300)
{
price=cunt*2;
[Link]("Pay amount : "+price);
}
else if(cunt>=100 && cunt<200)
{
price=cunt*1;
[Link]("Pay amount : "+price);
}
else
{
price=120;
[Link]("Pay amount : "+price);
}
}
}
import [Link];

class Swith
{
public static void main(String[] args) throws Exception
{
char c;
[Link]("Enter a character:");
c = (char)[Link]();
switch(c)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':[Link]("Vowel");
break;
default:[Link]("Consonents");
}}}

You might also like