Chapter 8(conditional construct) {
//Q10 input num check single digit or double //digit extraction
digit digit=num%10;
class Q1210 ctr=ctr+1;
{ //counting number of digits
void greater(int a, int b, int c) //s=s+digit;
{ num=num/10;
int max=0; }
max=(a>b)?(a>c)?a:c:(b>c)?b:c; //System.out.println("sum of digits="+s);
System.out.println("greatest System.out.println("sum of digits="+ctr);
number="+max);
} }
} }
//Q11. //q// q14 input char convert in opposite case,if
import java.util.*; inputted char is 'G' o/p 'g'
public class q11 class q14
{ {
void Compound() void conversion(char ch)
{ {
double ci=0.0,a=0.0,p=0.0,t=0.0,k=0.0,l=0.0; int c=0;
Scanner sc=new Scanner(System.in); if (ch>=65 && ch<=90)
{
c=(int)ch+32;
System.out.println("principal:"); }
p=sc.nextDouble(); else
System.out.println("time:"); {
t=sc.nextDouble(); c=(int)ch-32;
if(p<10001 && t<=3) }
{ char d=(char)c;
/* l=double(6/100); System.out.println("inputted charcter="+"
k=(double)(1+l); "+ch+"converted character="+d);
System.out.println("Amount="+l); }
System.out.println("Amount="+k); }
a=p*Math.pow(k,3);
**/ //Q16
a=p*Math.pow((1+0.06),3); class q16
ci=(a-p); {
System.out.println("Amount="+a); void electricitybill(int unit)
{
System.out.println("compound interest="+ci); double amount=0.0;
} if (unit<=100)
{
} amount=350;
} }
//Q12 greatest value among three numbers if (unit>100 && unit<=200)
class Q12 {
{ amount=350+(unit-100)*1.90;
void numdigit(int num) }
{ if (unit>200 && unit<=300)
int digit,ctr=0,s=0; {
while(num!=0) amount=350+100*1.90+(unit-200)*2.90;
} Q20
if (unit>300) import java.util.*;
{ class Q20
amount=350+100*1.90+100*2.90+(unit- {
300)*3.90; void dheck()
} {
System.out.println("amount of Scanner obj =new Scanner(System.in);
bill="+amount); System.out.println("enter character");
}
} char ch=obj.next().charAt(0);
Q18 /* Switch(ch)
//q18 {
import java.util.*; case 'A':
class q18 System.out.println(**/
{ if (ch>=65 && ch<=90)
void digitword()
{ System.out.println("capital letters");
Scanner obj =new Scanner(System.in); else if(ch>=97 && ch<=122)
System.out.println("enter digit"); System.out.println("small letters");
int n =obj.nextInt(); else
char ch=obj.next().charAt(0); System.out.println("special
switch(ch) characters");
{ }
case 'a': }
System.out.println("i m a result of character
input");
break;
/* switch(n)
{
case 1:
System.out.println("one");
break;
case 2:
System.out.println("two");
break;
case 3:
System.out.println("three");
break;
case 4:
System.out.println("four");
break;
case 5:
System.out.println("five");
break;
case 6:
System.out.println("six");
break;
default:
System.out.println("wrong choice");**/
}}}