In: Computer Science
every code should be in java Program 1: Write a while loop that sums the integers from 1 to 10, excluding 3 and 6. Print the sum. [Hint: Use logical operators] Program 2: Write a for loop that attempts to display the numbers from 1 to 10, but terminates when the control variable reaches the value 6. Program 3: Write a do...while loop that prints the integers from 10 to 0, inclusive.
//TestCode1.java
public class TestCode1 {
public static void main(String[] args) {
int i = 1, sum = 0;
while(i<=10){
if(i!=3 && i!=6)
sum += i;
i += 1;
}
System.out.println(sum);
}
}

46
///////////////////////////////////////////////////////////////////
//TestCode2.java
public class TestCode2 {
public static void main(String[] args) {
for(int i = 0;i<=10;i++){
if(i==6)
return;
System.out.println(i);
}
}
}


///////////////////////////////////////////////////////////////////////////
//TestCode3.java
public class TestCode3 {
public static void main(String[] args) {
int i = 10;
do{
System.out.println(i);
i-=1;
}while (i>=0);
}
}

