---///BLoODLinE=---
Would you like to react to this message? Create an account in a few clicks or log in to continue.

SimE Exer (tO bE printEd=-)

Go down

SimE Exer (tO bE printEd=-) Empty SimE Exer (tO bE printEd=-)

Post  Admin Fri Sep 19, 2008 2:41 pm

import javax.swing.JOptionPane;
public class Exer6A{
public static void main(String [] args){

int count = 1;
while (count <= 20) {
JOptionPane.showMessageDialog(null, + count);
count++;
}

}
}
_______________________

import javax.swing.JOptionPane;
public class Exer6B{
public static void main(String [] args){

double count = 7;
while (count <= 10) {
JOptionPane.showMessageDialog(null, + count);
count = count + 0.5;
}
}
}
______________

import javax.swing.JOptionPane;
import java.text.*;

public class Exer6C{
public static void main (String [] args){

double num = 3;

DecimalFormat Mj=new DecimalFormat ("0.0000");

while (num<=10){
JOptionPane.showMessageDialog(null, Mj.format(1/num));
num=num+1;
}
}
}

_______

import javax.swing.JOptionPane;
public class Exer6D {
public static void main(String[] args) {

int num=10;
while(num>=-10)
{
JOptionPane.showMessageDialog(null,num);
num = num-3;
}
}
}
_______

import javax.swing.JOptionPane;
public class Exer7A {
public static void main(String [] args) {

int A, B, P;

A = Integer.parseInt(JOptionPane.showInputDialog("pLEase entEr thE numBer A"));
B = Integer.parseInt(JOptionPane.showInputDialog("pLEase entEr thE numBer B"));

P = 1;


do
{
P = P*A;
A = A + 1;
}

while (A <= B);
JOptionPane.showMessageDialog(null, "thE proDuCt iS: " +P);
}
}

___

public class Exer7B {
public static void main(String [] args) {

int sum, c;

sum = 0;
c = 1;

do
{
c = c + 1;
sum = sum + c;
}

while (sum < 1000);
System.out.print("thE LaSt vaLuE aDDed iS: " +c);
c++;
}
}

________________


import javax.swing.JOptionPane;
public class Exer7C {
public static void main (String[]args) {

int num1, num2, c;
int num = 1;

num1=Integer.parseInt(JOptionPane.showInputDialog("inPuT thE FisrT inteGer"));
num2=Integer.parseInt(JOptionPane.showInputDialog("inpUt thE sEconD inTeger"));

for(c = 1; c < 10; c++)

{
num = num + 2 * (num2 - 1);
System.out.print(num +" ");
num = num -3;
}
}
}

______

import javax.swing.JOptionPane;
public class Exer7D {
public static void main(String [] args) {

int sum, c;

sum = 0;
c = 1;


while (sum < 1000)

{
c = c + 1;
sum = sum + c;
}

JOptionPane.showMessageDialog(null, "thE LaSt vaLuE aDDed iS: " +c);
c++;
}
}

_________

class Exer8 {
public static void main(String[] args) {

int[] Mj = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int searchfor = 11;

int i;
boolean foundIt = false;

for (i = 0; i < Mj.length; i++) {
if (Mj[i] == searchfor)
continue;

{
foundIt = true;
break;
}
}

if (foundIt) {
System.out.println("Found " + searchfor + " at index " + i);
} else {
System.out.println(searchfor + " not in the array");
}
}
}


_________

class Exer008 {
public static void main(String[] args) {

String searchMe = "michael john m. virtudazo";
int max = searchMe.length();
int numPs = 0;

for (int i = 0; i < max; i++) {
//interested only in m's
if (searchMe.charAt(i) != 'm')
continue;


//process m's
numPs++;
}


System.out.println("Found " + numPs + " m's in the string.");

}
}

Admin
Admin

Posts : 28
Join date : 2008-08-12
Age : 33
Location : oN thE other siDe!~

https://bl00dlin3.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum