Page 312 - CA_Blue( J )_Class10
P. 312
16 if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
17 { vc++; }
18 }
19 }
20 void display()
21 { System.out.println(str + " : Number of vowels " + vc); }
22 public static void main()
23 { Scanner sc= new Scanner(System.in);
24 String sen;
25 System.out.print("Enter a sentence : ");
26 sen=sc.nextLine();
27 vowel ob = new vowel(sen);
28 ob.count_vowels();
29 ob.display();
30 }
31 }
You will get the following output:
To create a class Salary with following specifications:
Program 4 Class name : salary
Data Members
String ename : To store name of the employee
String dept : To store name of the department
double basic : To store basic salary
double hra : To store House Rent Allowance
double da : To store Dearness Allowance
double tot_sal : To store the total salary
Methods
salary() : Constructor to initialize the data members
void input() : Inputs ename, dept, and basic
void calculate() : Calculates the hra as 15% of basic and da as 50% of basic.
void total_sal() : Total salary is calculated as basic + hra + da
void display() : Prints all the data members in the following format:
Name Department Basic HRA DA Total Salary
----- ----- ---- --- --- -------
1 import java.util.*;
2 class salary
3 {
310310 Touchpad Computer Applications-X

