JAVA Model Questions || BIM STUDY NOTES
Model Questions Write a Java program to display all the numbers between -300 to -1 which when divided by 17 gives 7 as remainder and also displays sum of those numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public class Sum { Â Â Â public static void main(String[] args) { Â Â Â Â Â Â Â int i,s=0; Â Â Â Â Â Â Â for(i=-300;i<-1;i++) Â Â Â Â Â Â Â { Â Â Â Â Â Â Â Â Â Â Â if(i%17==-7){ Â Â Â Â Â Â Â Â Â Â Â System.out.print(i+ " "); Â Â Â Â Â Â Â Â Â Â Â s = s+i; Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â System.out.println("The sum = "+s);Â Â Â Â Â Â Â }Â Â Â } |
3.Make two threads, one displays odd number after one second and another thread display even number after half second between -200 and -10. […]
Continue Reading