• Ritik Dwivedi
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 7
    Replies
https://trailhead.salesforce.com/en/content/learn/projects/workshop_mgmt/workshop_mgmt_apex
//Apex Programme to find the perfect squares between two numbers

public class PerfectSquare {
    public static void  perfectSqMethod(integer in1,integer in2){
        
        // For every element from the range between in1 and in2
          
        for(Integer i = in1; i<in2; i++){
                       
        double d1 = Math.sqrt(i);
        double d2 = math.round(d1);
            
        // If current number  is a perfect square 
        if (d1==d2) 
        system.debug(i);
    } 
                                      
                    
    }   
}

//calling method 
PerfectSquare.perfectSqMethod(10,100);
           
     

//Result
16
25
36
49
64
81
Does anyone have a any ebook of Apex Programming . Please share me 
Email id - dwivedi9039@gmail.com
Thanks in advance 
@isTest
private class WarrantySummaryTest {
    @isTest static void createCase(){
        Case myCase = new Case();
        myCase.Product_Purchase_Date__c   = Date.today();
        myCase.Product_Total_Warranty_Days__c = 10;
        myCase.Product_Has_Extended_Warranty__c = true;
        insert myCase;
            
    }

}
when  candidate enter date of birth he/she must be greater than 18 years. how can i write the conditional formula ?
how to get length of id 
for example 
id x  = 458sffrryh;
sytem.debug(x.length());


it will show error
public class MessageMaker {
    public static string helloMessage() {
return ('You say "Goodbye," I say "Hello"'); 
        system.debug('You say "Goodbye," I say "Hello"');
    }
    

}
how to call this method in anonymous window???
https://trailhead.salesforce.com/en/content/learn/projects/workshop_mgmt/workshop_mgmt_apex
@isTest
private class WarrantySummaryTest {
    @isTest static void createCase(){
        Case myCase = new Case();
        myCase.Product_Purchase_Date__c   = Date.today();
        myCase.Product_Total_Warranty_Days__c = 10;
        myCase.Product_Has_Extended_Warranty__c = true;
        insert myCase;
            
    }

}
public class MessageMaker {
    public static string helloMessage() {
return ('You say "Goodbye," I say "Hello"'); 
        system.debug('You say "Goodbye," I say "Hello"');
    }
    

}
how to call this method in anonymous window???

i am trying to caluclate AGE from Birthdate.

 

we have birthdate field  now. ( contact standard filed) .what is the best way to calculate age. can i write some formulae or trigger.

 

please advice 

 

Thanks.