0% found this document useful (0 votes)
25 views4 pages

UTS Pemrograman Bergerak

Uploaded by

Dani Cabbage
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)
25 views4 pages

UTS Pemrograman Bergerak

Uploaded by

Dani Cabbage
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/ 4

Muhammad Abduramadani_210403010049

package com.example.utspg;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {


Button loginBtn , resBtn;
EditText username, password , hasil;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username = findViewById(R.id.inputusername);
password = findViewById(R.id.inputpassword);
loginBtn = findViewById(R.id.login);
resBtn = findViewById(R.id.reset);
hasil = findViewById(R.id.hasil);

loginBtn.setOnClickListener((ev)-> {
String userUsername = username.getText().toString();
String userPassword = password.getText().toString();
if(userUsername.equals("dani") && userPassword.equals("12345")){
Intent page2 = new Intent(this, no2.class);
startActivity(page2);
}
});

resBtn.setOnClickListener((ev) -> {
username.setText("");
password.setText("");
});

}
}
package com.example.utspg;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

public class no2 extends AppCompatActivity {

Button hitung ;
EditText x1, x2, aInput, bInput, cInput;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no2);
hitung = findViewById(R.id.hitung);
x1 = findViewById(R.id.hasilx1);
x2 = findViewById(R.id.hasilx2);
aInput = findViewById(R.id.inputA);
bInput = findViewById(R.id.inputB);
cInput = findViewById(R.id.inputC);

hitung.setOnClickListener((ev) -> {
int a,b,c ;
double det;

a = Integer.parseInt(aInput.getText().toString());
b = Integer.parseInt(bInput.getText().toString());
c = Integer.parseInt(cInput.getText().toString());
det = Math.pow(b,2) - (4*a*c) ;

if(det == 0){
double akar = (double) -b / (2*a) ;
x1.setText(String.valueOf(akar));
x2.setText(String.valueOf(akar));

}else if(det > 0){


double x1res = (-b + Math.sqrt(det))/ (2 * a);
double x2res = (-b - Math.sqrt(det))/ (2 * a);
x1.setText(String.valueOf(x1res));
x2.setText(String.valueOf(x2res));
}else{
x1.setText("Imajiner");
x2.setText("Imajiner");
}
});

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy