This is Java programing The file fruittxt contains name of f

This is Java programing. The file (fruit.txt) contains name of fruitsYou may use ArryList to save the data into your memory. Your program choose one of the fruits using random method, then outputs the selected fruit name after using Collections.shuffle. User can answer the exact name of the fruit. You are required to use Collections.shuffle for this program. Don’t need to check whether the answer is collect or not.

B A N A N A
A P P L E
O R A N G E
G R A P E
A P R I C O T
H O N E Y B E R R Y
P A P A Y A
B L U E B E R R Y
C H E R R Y
R A S P B E R R Y
G R A P E F R U I T

Out put(Bold is User input)

R G E N A O

Orange

G P A R E

Grape

N A A N A B

Banana

Solution

package com.example.shreya.mychegg;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.*;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public static void main(String[] args) {

// create array list object
ArrayList arrayList = new ArrayList();

// populate the list

arrayList.add(\"BANANA\");
arrayList.add(\"APPLE\");
arrayList.add(\"ORANGE\");
arrayList.add(\"GRAPE\");
arrayList.add(\"APPRICOT\");
arrayList.add(\"HONEYBERRY\");
arrayList.add(\"PAPAYA\");
arrayList.add(\"BLUEBERRY\");
arrayList.add(\"CHERRY\");
arrayList.add(\"RASPBERRY\");
arrayList.add(\"GRAPEFRUIT\");



// print all available elements

for (Object num : arrayList) {
System.out.println(\"Element = \" + num);
}

while(true) {
// Shuffle the array
Collections.shuffle(arrayList);
System.out.println(arrayList);

String user = System.console().readLine();
System.out.println(\"Your guess\" + user);

}

}


}

This is Java programing. The file (fruit.txt) contains name of fruitsYou may use ArryList to save the data into your memory. Your program choose one of the frui
This is Java programing. The file (fruit.txt) contains name of fruitsYou may use ArryList to save the data into your memory. Your program choose one of the frui

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site