Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

solve usuing Andorid Studio. content_main.xml strings.xml Enter URL of file Display Boats Boats will be displayed here. sample data file Sea Ray D15F4 68 diesel

solve usuing Andorid Studio. image text in transcribed

content_main.xml

           

strings.xml

Enter URL of file Display Boats Boats will be displayed here.

sample data file

Sea Ray

D15F4

68

diesel

1175000.00

Formula

D5721

32

gasoline

109450.00

Hatteras

8C705

70

diesel

1999995.00

.java file- MainActivity.java

package com.example.boat; import android.os.Bundle; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.os.StrictMode; import android.view.View; import android.view.Menu; import android.view.MenuItem; import java.util.Scanner; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } @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_main, 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(); /oinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } public void displayBoats (View view){ Scanner fsc; fsc.nextLine(); //usuing It for string Double.parseDouble(fsc.nextLine()); // Integer.parseInt(fsc.nextLine()); } }
Lab Assignment #2 Write an app whose GUI looks like the following: Boat App Enter url of DISPLAY BOATS You should enter the entire URL of a file containing boat data in the Edit Text field labeled "Enter URL of file." Such a text (data) file (located on the Web) will contain data for three different boats. Let each data item sit on its own line in the text file. (The file will therefore contain 15 lines of data in total.) For example, the first five lines of the file might look like: Sea Ray D15F4 diesel 1175000.00 Your app should have a Main Activity method that responds to a press of the button "Display Boats" and does the following: (a) Creates three Boat objects. (Make certain to declare three separate Boat references and use these in the object creation process. You can use an array of boats (references) for this or even a list but it is not required.) (b) Reads all the boat data from the data file into the three respective Boat objects that you created. (c) Displays all the data for the three boats (retrieved from the objects) in the TextView below the button. (d) Displays the average length of the three boats (as a real number) in the TextView below the boat data. Display this value to one decimal place (for example. 40.3). (e) Displays the average price of the three boats in the TextView below the boat data. As usual for money. display the value to two decimal places (for example, S100000.59). Reminder: Do not forget to include the two lines in the "onCreate" method of the Main Activity pertaining to the "thread policy." See the handout on App File Input. Also, don't forget to give the app "Internet" permission. Lab Assignment #2 Write an app whose GUI looks like the following: Boat App Enter url of DISPLAY BOATS You should enter the entire URL of a file containing boat data in the Edit Text field labeled "Enter URL of file." Such a text (data) file (located on the Web) will contain data for three different boats. Let each data item sit on its own line in the text file. (The file will therefore contain 15 lines of data in total.) For example, the first five lines of the file might look like: Sea Ray D15F4 diesel 1175000.00 Your app should have a Main Activity method that responds to a press of the button "Display Boats" and does the following: (a) Creates three Boat objects. (Make certain to declare three separate Boat references and use these in the object creation process. You can use an array of boats (references) for this or even a list but it is not required.) (b) Reads all the boat data from the data file into the three respective Boat objects that you created. (c) Displays all the data for the three boats (retrieved from the objects) in the TextView below the button. (d) Displays the average length of the three boats (as a real number) in the TextView below the boat data. Display this value to one decimal place (for example. 40.3). (e) Displays the average price of the three boats in the TextView below the boat data. As usual for money. display the value to two decimal places (for example, S100000.59). Reminder: Do not forget to include the two lines in the "onCreate" method of the Main Activity pertaining to the "thread policy." See the handout on App File Input. Also, don't forget to give the app "Internet" permission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions