SlideServe
Menu
Préférences
© SlideServe · v2026

Extra Examples

hyman avatar
13 diapositives · 324 Views · Sep 07, 2014

Extra Examples. Duaa al-Saeed 14 Jun 2010. EX1. Write a program that reads two integers and then calls a method that receives the two integers and returns their greatest common divisor , which is printed in main. EX2.

Extra Examples - slide 1
01 / 13Extra Examples
1 / 17

Télécharger la présentation

Extra Examples
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Extra Examples Duaa al-Saeed 14 Jun 2010

  2. EX1 • Write a program that reads two integers and then calls a method that receives the two integers and returns their greatest common divisor, which is printed in main..

  3. EX2 • Write a program which calls a method named isMultiple. This method takes two integers values and determines whether the second integer is a multiple of the first. Main then prints an appropriate message. Sample run: Enter first number: 4Enter second number: 1616 is multiple of 4

  4. EX3 • Write a program that reads an integer x and calls a method divisors that prints all the divisors of x. Sample run: Enter an integer: 8 The divisors of 8: 1 2 4 8

  5. EX4 • Write a program that prompts the user to input an integer and then calls a method printDigits that receives the integer and outputs the individual digits of the number. Sample run: Enter an integer: 456 The individual digits of 456 are: 4 5 6

  6. EX5 • Write a program that reads two integers n and m then calls a method PrinTablethat prints first (m) elements in the multiplication table of the integer n. Sample run: Enter two integers: 2 5 The first 5 elements in the multiplication table of 2 are : 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10

  7. EX6 • Write a program with a method rnd1that receives a real number; and returns the number rounded to the nearest integer. And another method rnd2 that received a real number; and returns the number rounded to the nearest integer. rnd1 method should use the method Math.ceil, while rnd uses method Math.floor , main should read the real number from user and calls the two methods and print the 2 resulting integers.