Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please tell me how to create an android app that can run this problem. It is fro

ID: 3696718 • Letter: P

Question

Please tell me how to create an android app that can run this problem. It is from the book "APP INVENTOR FOR ANDROID" and needs to run on the AIStarter emulator. The answer needs to use "buttons" from the "designer' and "block" applications that on MIT App Inventor.Assuming there are no accidents or delays, the distance that a car travels down the interstate can be calculated with the following formula: Distance = Speed * Time A Car is traveling at 60 miles per hour. Design a program that displays the following: -The distance the car will travel in 5 hours -The distance the car will travel in 8 hours -The distance the car will travel in 12 hour

Explanation / Answer

public class calculatedistance1 extends JFrame { private JRadioButton smallButton; private JRadioButton mediumButton; private JRadioButton largeButton; ; // doesn't need to be (big) text area */ Public calculatedistance1() { class DetectInput implements ActionListener { public void actionPerformed(ActionEvent e) { calculatedistance(); } listener = new DetectInput(); JPanel sizePanel = createButtons(); JPanel toppingPanel = createBoxes(); // put first 2 panels into another panel to group them JPanel centerPanel = new JPanel(); centerPanel.add(sizePanel); centerPanel.add(toppingPanel); JPanel pricePanel = createOutput(); getContentPane().add(centerPanel, BorderLayout.CENTER); getContentPane().add(pricePanel, BorderLayout.SOUTH); pack(); } /** createButtons - Radio buttons for the size panel. */ public JPanel createButtons() { // make 3 buttons, and attach the listener to them; make medium default smallButton = new JRadioButton("distance after 5 hours"); mediumButton = new JRadioButton("distance after 8 hours "); largeButton = new JRadioButton("distance after 12 hours "); smallButton.addActionListener(listener); mediumButton.addActionListener(listener); largeButton.addActionListener(listener); mediumButton.setSelected(true); // We need a button group because we want only 1 button to appear chosen // at a time. ButtonGroup group = new ButtonGroup(); group.add(smallButton); group.add(mediumButton); group.add(largeButton); // make a panel for the radio buttons JPanel radioButtonPanel = new JPanel(); radioButtonPanel.setLayout(new GridLayout(3,1)); // do we need a border? radioButtonPanel.add(smallButton); radioButtonPanel.add(mediumButton); radioButtonPanel.add(largeButton); return radioButtonPanel; } public void calculatedistance() { int speed=60; int distance; if (smallButton.isSelected()) distance=speed*5; else if (mediumButton.isSelected()) distance=speed*8; else distance=speed*12; System.out.println(“ the distance is here”+distance); }