Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Untitled

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

<?xml version="1.0" encoding="utf-8"?

>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@drawable/pantalla1"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="363dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="CAJERO AUTOMATICO"
android:textColor="#020202"
android:textSize="30dp"
android:textStyle="bold">
</TextView>
</LinearLayout>
<EditText
android:id="@+id/etRetirar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#46539E"
android:gravity="center"
android:hint="Ingresa cantidad a retirar"
android:inputType="number">
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">

<Button
android:id="@+id/btnRetirar"
android:layout_width="match_parent"
android:onClick="Retirar"
android:layout_weight="1"
android:background="@drawable/botones"
android:textAllCaps="false"
android:textSize="18dp"
android:text="Retirar"
android:layout_height="wrap_content">
</Button>
<Button
android:id="@+id/btnTransaccion"
android:layout_width="match_parent"
android:onClick="Transacciones"
android:layout_weight="1"
android:background="@drawable/botones"
android:textAllCaps="false"
android:textSize="15dp"
android:text="NVA.Transaccion"
android:layout_height="wrap_content">
</Button>
<Button
android:id="@+id/btnSalir"
android:layout_width="match_parent"
android:onClick="Salir"
android:layout_weight="1"
android:background="@drawable/botones"
android:textAllCaps="false"
android:textSize="18dp"
android:text="Salir"
android:layout_height="wrap_content">
</Button>
</LinearLayout>

<TextView
android:id="@+id/Billetes"
android:layout_width="match_parent"
android:layout_height="287dp"
android:gravity="center_horizontal"
android:text=""
android:textSize="25dp"
android:textStyle="bold"></TextView>
<TextView
android:id="@+id/Resultado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:textStyle="bold"
android:gravity="left"
android:text="">
</TextView>
<TextView
android:id="@+id/saldo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:textStyle="bold"
android:gravity="left"
android:text="Saldo inicial: $30000">
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Creado por Luis Roberto y Juan David del Grupo 6AVP"
android:textStyle="bold"
android:textSize="25dp"
android:background="#0191FF"
android:layout_margin="10dp"
android:gravity="center"/>
//Luis Roberto Lara Segura y Juan David lopez
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>


<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#006847"
android:centerColor="#FFFFFF"
android:endColor="#CE1126"
/>
<corners
android:radius="30dp"
/>
<stroke
android:width="5dp"
android:color="#FFFFFF"
/>
</shape>

<?xml version="1.0" encoding="utf-8"?>


<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FF0000"
android:centerColor="#FFFFFF"
android:endColor="#000DFF"
/>
<corners
android:radius="30dp"
/>
<stroke
android:width="2dp"
android:color="#FFFFFF"
/>
</shape>

package com.example.prueba

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
var Saldo=30000
var restante=0
var real=0
//Luis Roberto Lara Segura y Juan David Lopez
fun Retirar(view: View){
try {
var retiro: Int = etRetirar.text.toString().toInt()
var saldo1 = Saldo
if (retiro <= 8000) {
if (retiro <= Saldo) {
var B1000=0
var B500=0
var B200=0
var B100=0
var B50=0
var B20=0
if (retiro >= 1000) {
var C1000 = 0;
C1000 = retiro / 1000
retiro = retiro - (C1000 * 1000)
B1000=C1000*1000
Billetes.append("\n Billetes de 1000: $C1000")
}
if (retiro >= 500) {
var C500 = 0;
C500 = retiro / 500
retiro = retiro - (C500 * 500)
B500=C500*500
Billetes.append("\n Billetes de 500 $C500")
}
if (retiro >= 200) {
var C200 = 0;
C200 = retiro / 200
retiro = retiro - (C200 * 200)
B200=C200*200
Billetes.append("\n Billetes de 200: $C200")
}
if (retiro >= 100) {
var C100 = 0;
C100 = retiro / 100
retiro = retiro - (C100 * 100)
B100=C100*100
Billetes.append("\n Billetes de 100: $C100")
}
if (retiro >= 50) {
var C50 = 0;
C50 = retiro / 50
retiro = retiro - (C50 * 50)
B50=C50*50
Billetes.append("\n Billetes de 50: $C50")

}
if (retiro >= 20) {
var C20 = 0;
C20 = retiro / 20
retiro = retiro - (C20 * 20)
B20=C20*20
Billetes.append("\n Billetes de 20: $C20")
}
real =B1000+B500+B200+B100+B50+B20
restante = Saldo - real
Resultado.setText("\n Cantidad real retirada:$$real")
saldo.setText("\n Saldo: $$restante")
}else{
Toast.makeText(this, "Saldo insuficiente", Toast.LENGTH_LONG).show()
}
}else{
Toast.makeText(this, "No puedes retirar mas de 8000", Toast.LENGTH_LONG).show()
}
} catch (mensaje: NumberFormatException){
Toast.makeText(this, "Ingresa datos antes de empezar",
Toast.LENGTH_LONG).show()
}
}
fun Transacciones(view:View){
etRetirar.setText("")
Billetes.text=""
Saldo=Saldo-real
Resultado.setText("")
}
fun Salir(view:View){
System.exit(0)
}
}

You might also like