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

I\'m not getting the output that I want with my method, so I was wondering if so

ID: 3742811 • Letter: I

Question

I'm not getting the output that I want with my method, so I was wondering if someone could help me figure out why things aren't working out how they should(rewrite/change code). I'm supposed to have a method that determines the number of times that an item is in a "Trio", which is just an object that holds three values.

Here's the code:

My troublesome output:

public class TrioDriver ( public static void main (String[] args) three: Trio test1 new Trio( one: "hello", two: "hello", Trio Integer> test2- new Trio(one: 1, two: 2, three: 3) /7 System.out.printin(test2.contains)) System.out.printin (testl.contains )) "hello"); TriDriver × "C:Program FilesJavajdk-10.0.1bìnjava.exe" "-java agent :C:Program FilesJetBrainsIntelliJ IDE Number of times first Parameter value is in Trio: 1 Number of times second Parameter value is in Trio:1 Number of times third Parameter value is in Trio: 1 Process finished with exit code0

Explanation / Answer

there was slightl mistake, i made it correct.

please give thumbs up, thanks

code:


public String contains() {
ArrayList<X> containList = new ArrayList<>();
containList.add(this.one);
containList.add(this.two);
containList.add(this.three);

HashMap<X,Integer>map = new HashMap<>(); //I learned about this HashMap by looking at somthing fairly similiar
for(int i=0;i<containList.size();i++){
if(map.containsKey(this.one)){
map.put(this.one,Integer.valueOf(String.valueOf(map.get(this.one)))+1);
}
else map.put(this.one,1);
}
for(int i=0;i<containList.size();i++){
if(map.containsKey(this.two)){
map.put(this.two,Integer.valueOf(String.valueOf(map.get(this.two)))+1);
}
else map.put(this.two,1);
}
for(int i=0;i<containList.size();i++){
if(map.containsKey(this.three)){
map.put(this.three,Integer.valueOf(String.valueOf(map.get(this.three)))+1);
}
else map.put(this.three,1);
}
int firstParamCount = map.get(this.one);
int secondParamCount = map.get(this.one);
int thirdParamCount= map.get(this.one);

String s= "Number of times first Parameter value is in Trio: "+firstParamCount+" "+
"Number of times second Parameter value is in Trio: "+secondParamCount+" "+
"Number of times third Parameter value is in Trio: "+thirdParamCount;
return s;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote