0% found this document useful (0 votes)
6 views

Untitled Document

Uploaded by

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

Untitled Document

Uploaded by

rawatanshu302
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

b1.setOnClickListener(new View.OnClickListener() { b1.setOnClickListener(new View.

OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View v) {
String s=e1.getText().toString(); String s = e1.getText().toString();
s=s.toLowerCase(); int n;
char ch;
int c = 0, vow=0; try {
int con=0, sp=0; n = Integer.parseInt(s);
} catch (NumberFormatException e) {
for(int i=0; i<s.length(); i++){ t1.setText("Please enter a valid
ch=s.charAt(i); number.");
c++; return;
if(ch==' ') }
sp++;
boolean isPrime = true;
if (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') if (n <= 1) {
vow++; isPrime = false; // Prime numbers are
else greater than 1
con++; } else {
} for (int i = 2; i <= n / 2; i++) {
t1.setText("Total Characters: "+c+"\n"+"Vowels: "+vow+"\ if (n % i == 0) {
n"+"Consonents: "+con+"\n"+"Spaces: "+sp); isPrime = false;
} break;
}
}
}
if (isPrime) {
t1.setText(n + " is a prime number.");
} else {
t1.setText(n + " is not a prime number.");
}
}
});

b1.setOnClickListener(new View.OnClickListener() { protected void onCreate(Bundle savedInstanceState)


@Override {
public void onClick(View view) { super.onCreate(savedInstanceState);
Double num1 = Double.parseDouble(e1.getText().toString()); EdgeToEdge.enable(this);
Double num2 = Double.parseDouble(e2.getText().toString()); setContentView(R.layout.activity_main);
Double sum = num1+num2;
String emp = Double.toString(sum); ViewCompat.setOnApplyWindowInsetsListener(findVi
t.setText(emp); ewById(R.id.main), (v, insets) -> {
} Insets systemBars =
}); insets.getInsets(WindowInsetsCompat.Type.systemB
b2.setOnClickListener(new View.OnClickListener() { ars());
@Override v.setPadding(systemBars.left,
public void onClick(View view) { systemBars.top, systemBars.right,
Double num1 = Double.parseDouble(e1.getText().toString()); systemBars.bottom);
Double num2 = Double.parseDouble(e2.getText().toString()); return insets;
Double diff = num1-num2; });
String emp = Double.toString(diff); Log.d("Lifecycle","on create calling");
t.setText(emp); }
} protected void onStart(){
}); super.onStart();
b3.setOnClickListener(new View.OnClickListener() { Log.d("Lifecycle","on start calling");
@Override }
public void onClick(View view) { protected void onResume(){
Double num1 = Double.parseDouble(e1.getText().toString()); super.onResume();
Double num2 = Double.parseDouble(e2.getText().toString()); Log.d("Lifecycle","on resume calling");
Double product = num1 * num2; }
String emp = Double.toString(product); protected void onPause(){
t.setText(emp); super.onPause();
} Log.d("Lifecycle","on pause calling");
}); }
b4.setOnClickListener(new View.OnClickListener() { protected void onRestart(){
@Override super.onRestart();
public void onClick(View view) { Log.d("Lifecycle","on restart calling");
Double num1 = Double.parseDouble(e1.getText().toString()); }
Double num2 = Double.parseDouble(e2.getText().toString()); protected void onStop(){
Double div = num1/num2; super.onStop();
String emp = Double.toString(div); Log.d("Lifecycle","on stop calling");
t.setText(emp); }
protected void onDestroy(){
super.onDestroy();
Log.d("Lifecycle","on destroy calling");
}
}

You might also like