Question: Follow the steps below to complete the Lab 1 1 . 1 . Create the project for Lab 1 1 2 . Add package CSCI

Follow the steps below to complete the Lab11.
1. Create the project for Lab11
2. Add package CSCI1010L
3. Add class Lab11
4. Add the main method:
public static main(String args[]){
}
5. Implement the followings within the main method:
a. Find the sum of the series: 1,3,5,7,9,11 using an array
//declare an array for the given series
int series[]={1,3,5,7,9,11};
int sum =0;
for(int i=0; i < series.length; i++){
sum = sum + series[i];
}
System.out.printf(The sum of the series: 1,3,5,7,9,11: %d
,sum);
b. Find the sum of the series: 1,2,3,4,5,6,7,8,9,10 without using an array
int sum =0;
for(int i=1; i <=10; i++){// i++ i = i +1
sum = sum + i;
}
System.out.printf(The sum of the series: 1,2,3,4,5,6,7,8,9,10: %d
,sum);
c. Find the sum of the series: 1,3,5,7,9,11 without using an array
int sum =0;
for(int i=1; i <=11; i+=2){// i = i+2 i+=2
sum = sum + i;
}
System.out.printf(The sum of the series: 1,3,5,7,9,11: %d
,sum);
d. Find & print the sum of the series: 5,10,15,20,25,30,35 without using an array
e. Find & print the sum of the series: 33,30,27,24,21,18,15 without using an array
6. Add a static method called:
public static void myStringOperations(){
}
Implement the followings in the myStringOperations() method:
a. Declare a String type variable called str and initialize with
"CSCI1010L-Programming I in Java"
b. Find and print the length of the String variable str:
str.length();
c. Find and print the index of the character P:
int index = str.indexOf(P);]
d. Find and print the index of -
e. Find and print the index of the white space character
f. Find and print the substring at the index found in 7.e
String str2= fullname.substring(index);
7. Add the following method call in the main method:
myStringOperations();
8. Run the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!