Tuesday, March 9, 2010

Tricep Dip Machine Vs Parallel Dips

Java Practice - 10 (Exception)

what you want from us boyutta olusturmamizi dizi ve bu dizi bi icerisinde aratmamizi istiyor Deger, Deger aratirken dizideki verilerin artan Sirad olmasini istiyor eger siralama artan degilse Istisna olusmasini you Deger bulmadan cikmasini istiyor, eger Deger bulunamazsa Yine bir Istisna olusturmamizi istiyor.

===========

Searching a vector

Write a function that searches an integer value in a vector of integers, or-ordinated

in ascending order. Both the value and the carrier are subjects of

function. The function returns the position of value in the vector, but lan-

`cia

an exception if it detects that the carrier passatole argument is not

`

ordered or if the value is not present in the vector. Then write a pro-

main program that reads from a keyboard and a vector value and calls the search function

, catch any exceptions.

=========================================

Cozum:

import IngressoUscita.Console;

public class Search {

/ / static asagidaki Dahila sinifimizi olarak belirliyoruz cunku static yapmazsak main bolumunde calistiramayiz ve bir haber Istisna firlatabilecegini veriyorus throws Exception ifadesi ile.

public static int ricerca (int val, int [] yes) throws Exception {

/ / Found that taking the value of a boolean variable to false.

boolean trovato = false;

int i = 0;

/ / the while that there are checking whether the value before the first cycle and i would like to control the number and length of the finely olmadigni are looking for value in the array i'ninci average value is small and equal olmadigni are checking.

while (! Trovato & & (i \u0026lt;vet.length) & & (vet [i] \u0026lt;= val)) {

/ / Here, bigger than 0, and if I check the directory are ascending towards the siralnip siralanmadigni

if (i> 0 & &! (vet [i]> = yes [i - 1])) {

/ / This is the idea of \u200b\u200bjeans with the exception of us can return an exception Create the

throw new Exception ("Non ordinato");}

/ / the value of the loop are going observed to

if (yes [i] == val) trovato = true;

else i + +;}

/ / Create the

exception here again if (! trovato) throw new Exception ("non e travato");

else return i;}

/ / public static void main section

writing main (String [] args) {

Console.scriviStringa ("Dimensione di array ");

Console.leggiIntero int n = ();

/ / user is the size of the array and would like to fill the array below.

int [] vettore = new int [n];

for (int i = 0; i \u0026lt;n, i + +) {

Console.scriviStringa ("insersci" + i);

vettore [i] = Console.leggiIntero ();

} / / user wants to search the value ask

Console.scriviStringa ("Valore di cercare ???");

int val = Console.leggiIntero ();

/ / Here an exception to the above are formed in the classroom are formed below the call oldugmuz ricerca try and catch the exception within exception where you catch the exception thrown from above between the user report the situation. Try {int

ricerca posizione = (val, vettore);

Console.scriviStringa ("Valore =" + posizione);

} catch (Exception e) {Console.scriviStringa ("ha trovato Excepion: "+ e.getMessage ());}

}}

Goood Rabbit Food Brands

Java Exercise -9 (Class)

ExcepionsAsagidaki question of us wants to develop a cryptology algorithm algorithm.

and written into one class and a String value Messagio wants us to. yazamamizi isyor encryption method and password, and 2 other methods to resolve.

This algorithm seeks to create a class for the two sub-

tane'de ROS and XOR, tie rod from the String class, and again to convey a message in a sequence by taking the string value by mode and up to the value of the string value of unicod grilen wants us to improve.

URL for XOR is written into a class by using the XOR operator isyor ..

=========================================

encrypted messages

Define Message in a class can contain a text message

(a string) and provides two abstract methods void figure (String k) and void

`

decrypt (String k) where k and the key used to encrypt and decrypt the message-

Thurs Then define two subclasses that implement the following mechanisms

encryption / decryption:

ROT `n The key k and a string that represents a number n. The algorithm encrypts the text

by replacing each letter with the one that follows the n-bit

provisions (circle) in the collection of Unicode encoding. The de-encryption

is similar: each letter of the encrypted message

is replaced with the letter that precedes the n positions (movement

mind) the whole of Unicode encoding.

`

XOR key ke a string of arbitrary length. The encryption is done by running the

xor between text characters and the characters of the key. In

if the text is longer than the key, the characters

of the latter are used in a circular fashion. The decryption

is doing exactly the same procedure on the ciphertext. Finally

Write a main program test in which references to

type messages are assigned objects of the two subtypes. Then, try to

Prints the text of the message after it has been encrypted and decrypted.

===========================================

Cozum:

figure package;

/ **

Sinif ismimiz abstract messages yapiyoruz cunku Altindere olusturacak oldugmuz siniflarin degerlerini kullana bilmek icin.

* / public

Messaggio abstract class {protected String data

;

public Messaggio (String s) {

/ / String value we get another one, this string will be our secret post we

data = s;}

/ / abstract and below Create the sub-classes for use in classes. Public abstract void

cifra (String chiave);

public abstract void decifra (String chiave);

/ / where the toString () String values \u200b\u200beasily can access and print using the data value. Public String toString

() {return data;}}

======================

/ / sub-class package cifra

;

/ **

order to create here the lower class, upper class that is derived from the identifier of this class to know that we have to use the phrase exdeds

* / public class tie rod extends

Messaggio {

public Wheel (String s) {

/ / where super () statement we create an object with the top

call super (s);

} public void

cifra (String c) {

/ / The following string value received from the integera translate.

int n = Integer.parseInt (c);

/ / and char [] array of super draws data from the data of our class We transfer to the array.

char [] aa = data.toCharArray ();

for (int i = 0; i \u0026lt;aa.length; i + +)

/ / Here, the data in the array of character strings one by one until reaching an increase each receive unicode mode are recorded.

aa [i] = (char) (aa [i] + n% 65536);

/ / The following message is encrypted into the data, writing data.

data = new String (aa);}

/ / Below we use the method to resolve the message is encrypted. Public void

decifra (String c) {

/ / message and will seek to resolve and Integer'a sifremizi again converting.

int n = Integer.parseInt (c);

/ / This is the time to send and print the subtraction method of making Cifra.

n = 65536 - n;

cifra (Integer.toString (n));

}}

====================== ===

Program:

cifra package;

IngressoUscita.Console import;

public class {public static void Proof

main (String [] args)

/ / Here, Rod olsuturyoruz our class using an object named m1 To know. Messaggio

{m1 = new Wheel ("Secret message");

/ / display first before the Rot mesajimizi yazdiriyoruz ...

Console.scriviStringa (m1.toString ());

/ / Sifremizi gonderiyoruz

m1.cifra ("35");

/ / Sifrelenmis mesajimizi yazdiriyoruz

Console.scriviStringa (m1.toString ());

m1.decifra ("35");

/ / ve tekrardan sifremizi gonderip mesajimizi cozuyoruz ..

Console.scriviStringa (m1.toString ());}

}