Walmart phone Interview questions

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-08-16Added By Anonymous
Source: Link

We have a product class

class Product{

String productName;

String category;

Double SoldAmount;

Public Product(){

}

}


write a function to get the sum of SoldAmount according to their category.


Input: List < Product > products


Output:


For example:

{“Toshiba”, “TV”, 40,000}

{“Samsung”, “TV”, 30,000}

{“GE”, “Appliance”, 20,000 }

{“Panasonic”, “Appliance”, 10,000}

Sum of SoldAmount of TV -> 40,000 + 30,000 = 70,000

Sum of SoldAmount of Appliance -> 20,000 + 10,000 = 30,000

Comments