Strings.
xml
<resources>
<string-array name="arraydestinos">
<item>Tumbes</item>
<item>Cuzco</item>
<item>Ancash</item>
<item>Arequipa</item>
</string-array>
</resources>
Content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Destino"
android:id="@+id/textView" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/arraydestinos"
android:id="@+id/spnDestino" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Linea"
android:id="@+id/textView2" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rdgLinea"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lan"
android:id="@+id/rbtLan"
android:checked="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avianca"
android:id="@+id/rbtAvianca"
android:checked="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Papagallo"
android:id="@+id/rbtTaca"
android:checked="false" />
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nombre"
android:id="@+id/textView3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtNombre" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dscto 10%"
android:id="@+id/chkDesc"
android:checked="false" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dscto 18%"
android:id="@+id/chkIgv"
android:checked="false" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reservar"
android:id="@+id/btnAceptar" />
</LinearLayout>
</RelativeLayout>
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity implements
[Link] {
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
btn=(Button)findViewById([Link]);
[Link](this);
}
public void onClick(View view) {
Spinner sp=(Spinner)findViewById([Link]);
RadioGroup rd=(RadioGroup)findViewById([Link]);
EditText edt =(EditText)findViewById([Link]);
CheckBox chkdes=(CheckBox)findViewById([Link]);
CheckBox chkigv=(CheckBox)findViewById([Link]);
double precio=0,incremento=0,desc=0,igv=0,total=0;
switch([Link]()){
case 0:precio=120;break;
case 1:precio=90;break;
case 2:precio=40;break;
case 3:precio=60;break;
}
switch([Link]()) {
case [Link]:incremento=0;break;
case [Link]:incremento=precio*0.08;break;
case [Link]:incremento=precio * 0.05;break;
}
precio = precio +incremento;
if([Link]()){
desc = precio * 0.10;
}
if([Link]()){
igv = precio * 0.18;
}
total = precio + igv - desc;
String res="Precio "+precio+
"\nDescuento "+desc+
"\nIGV "+igv+
"\nTotal "+total;
[Link](this,res,Toast.LENGTH_LONG).show();
}
}