Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please provide a solution on how to calculate the pizza price. Here are the GUI codes for application above. ____________________________________________________________________________________ package com.example.danielchoo.lab2; import android.support.v7.app.AppCompatActivity; import
Please provide a solution on how to calculate the pizza price.
Here are the GUI codes for application above.
____________________________________________________________________________________
package com.example.danielchoo.lab2; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; import java.text.NumberFormat; public class MainActivity extends AppCompatActivity { //Define the Radio group 1 and 2 RadioGroup myRG1, myRG2; // Pizza crust and order option RadioButton crispy, thick, soggy, restaurant, deliver, pickup; // Pizza topping options CheckBox myCB1, myCB2, myCB3, myCB4; // Pizza size SeekBar mySB; // text view for price TextView tv, tv1, tv2; // Variables used to calculate the total cost @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myRG1 = (RadioGroup)findViewById(R.id.radiogroup1); myRG2 = (RadioGroup)findViewById(R.id.radiogroup2); myCB1 = (CheckBox)findViewById(R.id.checkBox); myCB2 = (CheckBox)findViewById(R.id.checkBox2); myCB3 = (CheckBox)findViewById(R.id.checkBox3); myCB4 = (CheckBox)findViewById(R.id.checkBox4); mySB = (SeekBar)findViewById(R.id.seekBar); tv = (TextView)findViewById(R.id.textView5); // pizza size inch tv1 = (TextView)findViewById(R.id.TotalPrice); tv2 = (TextView)findViewById(R.id.Price); // total price present // Setting Radio button group 1 crispy = (RadioButton)findViewById(R.id.crispy); thick = (RadioButton)findViewById(R.id.thick); soggy = (RadioButton)findViewById(R.id.soggy); // Setting Radio button group 2 restaurant = (RadioButton)findViewById(R.id.restaurant); pickup = (RadioButton)findViewById(R.id.pickup); deliver = (RadioButton)findViewById(R.id.deliver); // Radio Group of Crust myRG1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int currentId = myRG1.getCheckedRadioButtonId(); RadioButton currentRB = (RadioButton)findViewById(currentId); Toast.makeText(getApplicationContext(), currentRB.getText(), Toast.LENGTH_SHORT); } }); // Radio Group of Togo or no myRG2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int currentId = myRG2.getCheckedRadioButtonId(); RadioButton currentRB = (RadioButton)findViewById(currentId); Toast.makeText(getApplicationContext(), currentRB.getText(), Toast.LENGTH_SHORT); } }); myCB1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB1 && isChecked) Toast.makeText(getApplicationContext(), myCB1.getText(), Toast.LENGTH_SHORT).show(); } }); myCB2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB2 && isChecked) Toast.makeText(getApplicationContext(), myCB2.getText(), Toast.LENGTH_SHORT).show(); } }); myCB3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB3 && isChecked) Toast.makeText(getApplicationContext(), myCB3.getText(), Toast.LENGTH_SHORT).show(); } }); myCB4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB4 && isChecked) Toast.makeText(getApplicationContext(), myCB4.getText(), Toast.LENGTH_SHORT).show(); } }); mySB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tv.setText(progress + " in"); } @Override public void onStartTrackingTouch(SeekBar seekBar) { Toast.makeText(MainActivity.this,"started", Toast.LENGTH_SHORT); } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } }Create a pizza pricing application shown as follows: MainActivity Crust Topping Crispy Thick Soggy Anchovies Pineapple Garlic Okra To go or no? At restaurant O Pickup Deliver Size 29 in $33.03 o o o $.05 per square inch $.05 per topping per square inch Different crust types No surcharge for crispy $2.50 extra for thick crust $5.00 extra for soggy crust - o Different delivery options At the restaurant or pickup, no charge Delivery charge is S3.00 - The application will react whenever the state of a control changes Create a pizza pricing application shown as follows: MainActivity Crust Topping Crispy Thick Soggy Anchovies Pineapple Garlic Okra To go or no? At restaurant O Pickup Deliver Size 29 in $33.03 o o o $.05 per square inch $.05 per topping per square inch Different crust types No surcharge for crispy $2.50 extra for thick crust $5.00 extra for soggy crust - o Different delivery options At the restaurant or pickup, no charge Delivery charge is S3.00 - The application will react whenever the state of a control changes
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started