File tree Expand file tree Collapse file tree
sanjay/src/main/java/com/lftechnology/phpjava Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .lftechnology .phpjava .one ;
2+
3+ import com .lftechnology .phpjava .pbAccess .PBAccess ;
4+
5+ public class Hello {
6+ public static void main (String [] arg ){
7+ PBAccess pb = new PBAccess ();
8+ pb .runPB ();
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ package com .lftechnology .phpjava .pbAccess ;
2+
3+ import java .util .Scanner ;
4+
5+ public class PBAccess {
6+ public void helloWorld (){
7+ System .out .println ("Public Access" );
8+ }
9+
10+ public String getNames (String fname ) {
11+ String [] splitName = fname .split (" " );
12+ String newName = "" ;
13+ String ct = "" ;
14+ for (int i =0 ; i < splitName .length ; i ++) {
15+ if (i >0 ) {
16+ newName += ct + splitName [i ];
17+ ct = " " ;
18+ }
19+ }
20+ return "Salutation:" +splitName [0 ]+", Full Name:" +newName ;
21+ }
22+
23+
24+ public int getSumOfMultiple (int n ,int m1 , int m2 ) {
25+ int sum = 0 ;
26+ for (int i = 0 ; i <n ; i ++) {
27+ if ((i %m1 ) == 0 || (i %m2 )==0 ) {
28+ sum += i ;
29+ }
30+ }
31+ return sum ;
32+ }
33+
34+ public void runPB (){
35+ Scanner scanIn = new Scanner (System .in );
36+ String fullName ;
37+ System .out .println ("Enter name with salutation: " );
38+ fullName = scanIn .nextLine ();
39+ int n ;
40+ int m1 ;
41+ int m2 ;
42+ System .out .println ("Enter total number of multiples" );
43+ n = scanIn .nextInt ();
44+ System .out .println ("Enter multiplier m1:" );
45+ m1 = scanIn .nextInt ();
46+ System .out .println ("Enter multiplier m2:" );
47+ m2 = scanIn .nextInt ();
48+ scanIn .close ();
49+
50+
51+ System .out .println (this .getNames (fullName ));
52+ System .out .println ("Sum of multiple by " +m1 +" and " +m2 +" below " +n +" is " +this .getSumOfMultiple (n , m1 , m2 ));
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments