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

**max points Hello, I am receiving an illegal/unsafe operations compiler error,

ID: 3632072 • Letter: #

Question

**max points

Hello, I am receiving an illegal/unsafe operations compiler error, I'm pretty sure its because I am not using the right <> syntax with the vectors. Would appreciate some assistance please!



import java.util.Collections;
import java.util.Random;
import java.util.Vector;

enum CreditCard {Visa, MasterCard, AmericanExpress, Lowes, BJs, HomeDepot, DinersClub, Debit};
enum Photos {Spouse, Dog, Cat, Pet, Children, Friend, Parents, Grandparents};
enum MiscCards {DriverLicense, MilitaryID, SSNCard, BloodDonor, Insurance, Library, RecordOfConviction, BarnesAndNoble, Borders};
enum PaperCurrency {One, Five, Ten, Twenty, Fifty, Hundred};

public class VectorStuff{
static Vector = new Vector();
static Random rnd = null;

public static void main(String[] args){
rnd = new Random();
int numCreditCardstoAdd = genRandomNumWithinRange(2,5,rnd); //Adding Credit Cards to Wallet
for(int i=0;i<numCreditCardstoAdd;i++){
int enumIndexRandom = genRandomNumWithinRange(0, 7, rnd);
wallet.add(CreditCard.values()[enumIndexRandom]);}

int numPhotostoAdd = genRandomNumWithinRange(0,10,rnd); //Adding Photos to Wallet
for(int i=0;i<numPhotostoAdd;i++){
int enumIndexRandom = genRandomNumWithinRange(0, 7, rnd);
wallet.add(Photos.values()[enumIndexRandom]);}

int numMiscCradstoAdd = genRandomNumWithinRange(3,6,rnd); //Adding Misc Cards to Wallet
for(int i=0;i<numMiscCradstoAdd;i++){
int enumIndexRandom = genRandomNumWithinRange(0, 8, rnd);
wallet.add(MiscCards.values()[enumIndexRandom]);}

int numPaperCurrencyAdd = genRandomNumWithinRange(0,20,rnd);//Adding Paper Currency to Wallet
for(int i=0;i<numPaperCurrencyAdd;i++){
int enumIndexRandom = genRandomNumWithinRange(0, 5, rnd);
wallet.add(PaperCurrency.values()[enumIndexRandom]);}

Collections.shuffle(wallet);//Shuffling the wallet
printCredicards();
printPhotos();
printMiscCards(); //Printing Wallet
printPaperCurrency();
} //end of main

private static void printCredicards(){
System.out.println("Credit Cards : ");
for(int i=0;i<wallet.size();i++){
if(wallet.get(i) instanceof CreditCard){
System.out.println(wallet.get(i).toString());}}}

private static void printPhotos(){
System.out.println("Photos : ");
for(int i=0;i<wallet.size();i++){
if(wallet.get(i) instanceof Photos){
System.out.println(wallet.get(i).toString());}}}

private static void printMiscCards(){
System.out.println("Misc. Cards : ");
for(int i=0;i<wallet.size();i++){
if(wallet.get(i) instanceof MiscCards){
System.out.println(wallet.get(i).toString());}}}

private static void printPaperCurrency(){
System.out.println("Paper Currency : ");
for(int i=0;i<wallet.size();i++){
if(wallet.get(i) instanceof PaperCurrency){
System.out.println(wallet.get(i).toString());}}}

private static int genRandomNumWithinRange(int min, int max, Random rand){
long wange = (long)(max - min + 1);
long fraction = (long)(wange * rand.nextDouble());
int randomval = (int)(fraction + min);
return randomval;}
}

Explanation / Answer

import java.util.Collections; import java.util.Random; import java.util.Vector; enum CreditCard {Visa, MasterCard, AmericanExpress, Lowes, BJs, HomeDepot, DinersClub, Debit}; enum Photos {Spouse, Dog, Cat, Pet, Children, Friend, Parents, Grandparents}; enum MiscCards {DriverLicense, MilitaryID, SSNCard, BloodDonor, Insurance, Library, RecordOfConviction, BarnesAndNoble, Borders}; enum PaperCurrency {One, Five, Ten, Twenty, Fifty, Hundred}; public class vectorstuff{ static Vector = new Vector(); static Random rnd = null; public static void main(String[] args){ rnd = new Random(); int numCreditCardstoAdd = genRandomNumWithinRange(2,5,rnd); //Adding Credit Cards to Wallet for(int i=0;i