Apex Development Challenges

- Challenge 1
Informatrix Academy wants to manage its website "academy.informatrix.com" The site has hundreds of technical
articles and written by many users
Each article is assigned a category, and this means once category can have mutiple post.
Example 
Category: Apex
Posts:
1. Apex Basic
2. Loops
Category: Lightning
Posts:
1. Aura Component
2. Loops in JS
you need to print all posts and their respective categories


- Challenge 2 Operators
aamir & Salman & sharukh love pizza they want to their favourite
restaurant and ordered pizza and ordered a few slices
total bill amount was $53, however, they were not sure how to split the bill
Do you think you can help them?

Split the bill
1 slice - $8/slice
2-3 slice - $7/slice
>3 slice - $6/slice

Aamir ordered - 3 slices
Salman ordered - 1 slice
Sarkuh ordered - 4 slice



- Challenge 3 Conditional Statements
Leap year probelm 
a leap year has 366 days write a program to find out if a year is a leap year or not
> a year is a leap year if it is evenly divisble by 4
> Except if that is year is also evenly divisible by 100
> unless the year is also evenly divisible by 400

Example 
2000 is a leap year
2200 is a not a leap year
divisible by 4 = leap
divisible by 100 = not leap
divosible by 400 = leap


- Challenge 4 Do while loop
Fizzbuzz Problem
Print all numbers from 0 to 100 but
> if a number is divisible by 3 print fizz instead of the number
> if a number is divisible by 5 print buzz instead of the number
> if a number is divisible by both 3 & 5. print fizzbuzz instead of number
Example: 
1, 2, fizz, 4, buzz, ....., 14, fizzbuzz, ...


- Challenge 5 while loop
print first 20 fibonacci numbers
0, 1, 1, 2, 3, 5, 8
0 & 1 - first 2 numbers
1 > 0+1
2 > 1+1
3 > 2+1
5 > 3+2


- Challenge 6 For Loop
The Pattern Challenge 
Integer n = 5;
*
* *
* * *
* * * *
* * * * *

- Challenge 7 Apex Methods Challenge
Create a class with name 'Fitness' which has couple of methods to calculate human fitness.
> BMI Calculator Method
create a method with name 'calculateBMI' which accepts necessary paramters and return bmi value.
Formula: (Body Weight in KG)/(Body Height in meter)2
> Pace Calculator Method
Create a method with name 'calculatePace' which accepts necessary parameters and return km per hour.
Pace Formula (km/minute) to use
(distance in km)/(time in minutes)


- Challenge 8 Apex Methods Challenge = Home Loan EMI Calculator
- Challenge 9 Apex Methods Challenge = GST Calculator

- Challenge 10 Write Unit Test Classes for the Fitness, HomeLoanEMI, GSTCalculator Class

- Challenge 11 
Step 1: Write a SOQL query to retrieve all Contacts from Salesforce Org. Retrieved results 
should show Contact Name, Title, Phone, Email.
Step 2: Modify SOQL query to retrieve only those contacts with title 'VP Technology'.
Step 3: Modify SOQL, and add another field called 'Department' in the results.
This field should be the 2nd Field in the results.
Step 4: Modify SOQL retrieve all results satisfying step 2 condition and has department value as 'Finance'
Step 5: Modify SOQL, inculde all SVP and VP in your search results. Make sure your results still meets step 4 condition
Step 6: Sort results by name in descending order.
Step 7: Limit Search results to only 3

- Challenge 12
SOOL Challenge
Account is a parent object of Contact. 
Contact is a parent object of Case.
Step #1 - Retrieve Name, Department and Title of all Contacts 
Step #2 - Retrieve all Cases (CaseNumber. Subject) raised by the contact 
Step #3 - Get parent Account's Name, Rating for each Contact 
Step #4 - Make sure Account fields are the initial columns in results 
Step #5 - Retrieve only those records where Account Rating is Hot 
Step #6 - Sort results by Contact Name 
Step #7 - Only retrieve open cases (use IsClosed Checkbox field value) 
Step #8 - Add one more filter condition, Contact Department must be equals to Technology


- Challenge 13 = DML Challenge
Create a new Account with name "WingNut Films" and Rating "Warm" 
Create a new Opportunity "Lord Of The Rings" for this Account with below field values
* Stage > Qualification
* Closed Date > Today 
Update Account Name to "New Line Cinema" 
Update Opportunity Stage to "Closed-Won"
Delete the opportunity 
Undelete the opportunity
Repeat the challenge using generic SObject type
 

- Challenge 14
Bulkification Challenge
Informatrix Academy uses Salesforce platform to run their business. Recently they introduced a new process to track the avg case resolution 
days for each of its customer. The IT team has created a new number field "Avg-Case_Resolution_Days__c' on account object.

A developer has written a method 'updateAvg CaseResolutionDays" to correctly update this field on Account object. The team 
noticed that the current code does not work for multiple accounts and can only work for one account at a time.
Your Job Is To Bulkify Current Method To Handle Multiple Account Update At Once.


- Challenge 15
Apex Trigger Challenge
Contact has a checkbox field "Active". The Account object has a number field "Active Contacts".
You need to show total active child contacts on parent account.
Make sure your code works in bulk operations as well.

This is Open Community Blogger Platform and community forum of SFDC professionals interested to share their experiences, ideas, and thoughts or any content invaluable to help others in this domain.