• chaitanyakuamar Teru
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
# create a map
chirutha          -     ramcharan
magadheer     -     ramcharan
orange            -     ramcharan
billa                 -     prabhas 
bhahuballi       -     prabhas 
mirchi              -     prabhas 

Data having be like
moviename    -    rating       -       collection 
chirutha          -     3             -       12cr
magadheer     -     4             -       75cr
orange            -     2             -       12cr
billa                 -     3             -       30cr
bhahuballi       -     4             -       1000cr
mirchi              -     4             -       50cr
how can we declare above data in MAP(collection)
# create a map
chirutha          -     ramcharan
magadheer     -     ramcharan
orange            -     ramcharan
billa                 -     prabhas 
bhahuballi       -     prabhas 
mirchi              -     prabhas 

#Data having be like
moviename    -    rating       -       collection 
chirutha          -     3             -       12cr
magadheer     -     4             -       75cr
orange            -     2             -       12cr
billa                 -     3             -       30cr
bhahuballi       -     4             -       1000cr
mirchi              -     4             -       50cr

# output will be like
   
we have to print like: Ramcharan acted in '3' movies .2 movies (chirutha , magadheera) hit with a collection of (12+75)=(87cr). 1 movie(orange) will be flop with the collection of (12cr).
# similar to the second one (prabahas)
hint : here movie rating between 1-2  declare as (flop), 3 will be declare as (average), 4& above will be declare as (hit)


# output :
actor name + total movies  + hit movie names & collection + avg movie name & collections + flop movie name & collections .
# output will be like in bellow format
ex : ram charan +total movies (3) + (chirutha,magadheera) hit movie collection (87cr) + no avg movie fr ramcharan + (orange) flop movie collection (12cr). 

 
1=list<String> firstcolourlist=new list<String>{'red','blue','yellow','orange','blue','red'};
    2=  list<String>secondcolourlist=new list<String>{'blue','black','yellow','green','blue'};

if we compare list1 - list2 or list2 - list1  we have to print common values in both lists along with their count
# create a map
chirutha          -     ramcharan
magadheer     -     ramcharan
orange            -     ramcharan
billa                 -     prabhas 
bhahuballi       -     prabhas 
mirchi              -     prabhas 

Data having be like
moviename    -    rating       -       collection 
chirutha          -     3             -       12cr
magadheer     -     4             -       75cr
orange            -     2             -       12cr
billa                 -     3             -       30cr
bhahuballi       -     4             -       1000cr
mirchi              -     4             -       50cr

# output will be like
   
Ramcharan acted in '3' movies .2 movies (chirutha , magadheera) hit with a collection of (12+75)=(87cr). 1 movie(orange) will be flop with the collection of (12cr).
# similar to the second one (prabahas)
hint : here movie rating between 1-2  declare as (flop), 3 will be declare as (average), 4& above will be declare as (hit)

 

 
1=list<String> firstcolourlist=new list<String>{'red','blue','yellow','orange','blue','red'};
    2=  list<String>secondcolourlist=new list<String>{'blue','black','yellow','green','blue'};

print the common values
            
correct these code am not getting proper result....
list 1 am adding another value like already existing value bt am getting wrong result.  
list<string>fcl= new list<string>();
fcl.add('red');
fcl.add('blue');
fcl.add('yellow');
fcl.add('orange');
fcl.add('blue');
system.debug('fcl'+fcl);
list<string>scl= new list<string>{'blue','black','yellow','green','blue'};
system.debug('scl'+scl);
map<string,integer>cc= new map<string,integer>();
for(string s1:fcl){
    for(string s2:scl){
        if(s1==s2){
            if(cc.containskey(s1)){
                cc.put(s1,cc.get(s1)+1);
            }
            else{
                cc.put(s1,2);
            }
        }
    }
}
system.debug('cc v'+cc);

Q.Print and count the unique values from firstColorList, secondColorList  along with the exact count. (red-2,blue-3,yellow-1,black-1,green-1) and ovral count 6

list<String> firstcolourlist=new list<String>{'red','blue','yellow','orange'};
        list<String>secondcolourlist=new list<String{'blue','black','yellow','green','blue'};
           
list<String> f1=new list<String>{'red','blue','yellow','orange'};
 list<String>s1=new list<String>{'blue','black','yellow','green','blue'};
         
Q.compare both list's & print the common values along with count 
# create a map
chirutha          -     ramcharan
magadheer     -     ramcharan
orange            -     ramcharan
billa                 -     prabhas 
bhahuballi       -     prabhas 
mirchi              -     prabhas 

Data having be like
moviename    -    rating       -       collection 
chirutha          -     3             -       12cr
magadheer     -     4             -       75cr
orange            -     2             -       12cr
billa                 -     3             -       30cr
bhahuballi       -     4             -       1000cr
mirchi              -     4             -       50cr

# output will be like
   
Ramcharan acted in '3' movies .2 movies (chirutha , magadheera) hit with a collection of (12+75)=(87cr). 1 movie(orange) will be flop with the collection of (12cr).
# similar to the second one (prabahas)
hint : here movie rating between 1-2  declare as (flop), 3 will be declare as (average), 4& above will be declare as (hit)

 

 
1=list<String> firstcolourlist=new list<String>{'red','blue','yellow','orange','blue','red'};
    2=  list<String>secondcolourlist=new list<String>{'blue','black','yellow','green','blue'};

print the common values
            
correct these code am not getting proper result....
list 1 am adding another value like already existing value bt am getting wrong result.  
list<string>fcl= new list<string>();
fcl.add('red');
fcl.add('blue');
fcl.add('yellow');
fcl.add('orange');
fcl.add('blue');
system.debug('fcl'+fcl);
list<string>scl= new list<string>{'blue','black','yellow','green','blue'};
system.debug('scl'+scl);
map<string,integer>cc= new map<string,integer>();
for(string s1:fcl){
    for(string s2:scl){
        if(s1==s2){
            if(cc.containskey(s1)){
                cc.put(s1,cc.get(s1)+1);
            }
            else{
                cc.put(s1,2);
            }
        }
    }
}
system.debug('cc v'+cc);

Q.Print and count the unique values from firstColorList, secondColorList  along with the exact count. (red-2,blue-3,yellow-1,black-1,green-1) and ovral count 6

list<String> firstcolourlist=new list<String>{'red','blue','yellow','orange'};
        list<String>secondcolourlist=new list<String{'blue','black','yellow','green','blue'};