Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. package com.example.android.gvt;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.MenuItem;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.TextView;
  11.  
  12. public class Main5Activity extends AppCompatActivity {
  13.  
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_main5);
  18. }
  19.  
  20. @Override
  21. public boolean onCreateOptionsMenu(Menu menu) {
  22. // Inflate the menu; this adds items to the action bar if it is present.
  23. getMenuInflater().inflate(R.menu.menu_main5, menu);
  24. return true;
  25. }
  26.  
  27. @Override
  28. public boolean onOptionsItemSelected(MenuItem item) {
  29. // Handle action bar item clicks here. The action bar will
  30. // automatically handle clicks on the Home/Up button, so long
  31. // as you specify a parent activity in AndroidManifest.xml.
  32. int id = item.getItemId();
  33.  
  34. //noinspection SimplifiableIfStatement
  35. if (id == R.id.action_settings) {
  36. return true;
  37. }
  38.  
  39. return super.onOptionsItemSelected(item);
  40. }
  41.  
  42. Intent intent = this.getIntent();
  43. int tel = intent.getIntExtra("tel", 100);
  44. int vel = intent.getIntExtra("vel", 0);
  45. int tv = intent.getIntExtra("tv", 0);
  46.  
  47. int codigo = tel+vel+tv;
  48.  
  49. double primeiro = 20;
  50. double quarto = 30;
  51. double doze = 50;
  52. double taxa = 10;
  53.  
  54. if(codigo == 100){
  55. primeiro = 89.90;
  56. quarto = 89.90;
  57. doze = 89.90;
  58. taxa = 15;
  59. }
  60.  
  61. switch(codigo){
  62. case 100:
  63. primeiro = 89.90;
  64. quarto = 89.90;
  65. doze = 89.90;
  66. taxa = 15;
  67. break;
  68. case 200:
  69. primeiro = 109.90;
  70. quarto = 109.90;
  71. doze = 109.90;
  72. taxa = 15;
  73. break;
  74. default:
  75. primeiro = 0;
  76. quarto = 0;
  77. doze = 0;
  78. taxa = 0;
  79. break;
  80. }
  81.  
  82.  
  83. public void displayPrecos(double primeiro, double quarto, double doze, double taxa) {
  84. TextView primeiroMes = (TextView) findViewById(R.id.primeiroMes);
  85. primeiroMes.setText(String.valueOf(primeiro));
  86. TextView quartoMes = (TextView) findViewById(R.id.quartoMes);
  87. quartoMes.setText(String.valueOf(quarto));
  88. TextView dozeMes= (TextView) findViewById(R.id.dozeMes);
  89. dozeMes.setText(String.valueOf(doze));
  90. TextView taxaFinal = (TextView) findViewById(R.id.taxa);
  91. taxaFinal.setText(String.valueOf(taxa));
  92. TextView taxaUm = (TextView) findViewById(R.id.taxaUm);
  93. taxaUm.setText(String.valueOf(taxa+primeiro));
  94. }
  95.  
  96. public void calcula (View view) {
  97. displayPrecos(primeiro, quarto, doze, taxa);
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement