Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.gvt;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- public class Main5Activity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main5);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main5, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- Intent intent = this.getIntent();
- int tel = intent.getIntExtra("tel", 100);
- int vel = intent.getIntExtra("vel", 0);
- int tv = intent.getIntExtra("tv", 0);
- int codigo = tel+vel+tv;
- double primeiro = 20;
- double quarto = 30;
- double doze = 50;
- double taxa = 10;
- if(codigo == 100){
- primeiro = 89.90;
- quarto = 89.90;
- doze = 89.90;
- taxa = 15;
- }
- switch(codigo){
- case 100:
- primeiro = 89.90;
- quarto = 89.90;
- doze = 89.90;
- taxa = 15;
- break;
- case 200:
- primeiro = 109.90;
- quarto = 109.90;
- doze = 109.90;
- taxa = 15;
- break;
- default:
- primeiro = 0;
- quarto = 0;
- doze = 0;
- taxa = 0;
- break;
- }
- public void displayPrecos(double primeiro, double quarto, double doze, double taxa) {
- TextView primeiroMes = (TextView) findViewById(R.id.primeiroMes);
- primeiroMes.setText(String.valueOf(primeiro));
- TextView quartoMes = (TextView) findViewById(R.id.quartoMes);
- quartoMes.setText(String.valueOf(quarto));
- TextView dozeMes= (TextView) findViewById(R.id.dozeMes);
- dozeMes.setText(String.valueOf(doze));
- TextView taxaFinal = (TextView) findViewById(R.id.taxa);
- taxaFinal.setText(String.valueOf(taxa));
- TextView taxaUm = (TextView) findViewById(R.id.taxaUm);
- taxaUm.setText(String.valueOf(taxa+primeiro));
- }
- public void calcula (View view) {
- displayPrecos(primeiro, quarto, doze, taxa);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement