Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner ;
- public class Exercice11
- {
- public static void main(String[] args)
- {
- char restart ;
- int value , test , value_base ;
- Scanner read = new Scanner(System.in);
- String ordinal ;
- do
- {
- System.out.println("rentrez votre nombre Γ convertir : ");
- value_base = read.nextInt();
- test = value_base % 10;
- value = (value_base/10)%10 ;
- if ( value == 1)
- {
- ordinal = "th";
- }
- else
- {
- switch(test)
- {
- case 1 : ordinal = "st"; break;
- case 2 : ordinal = "nd"; break;
- case 3 : ordinal = "rd"; break;
- default : ordinal = "th"; break;
- }
- }
- System.out.println(" votre nombre est : "+ value_base+" son ordinal est : "+value_base+ordinal);
- do
- {
- System.out.println("voulez vous recommencer y/n?");
- restart = read.next().charAt(0);
- }while (restart != 'y' && restart !='n' );
- }while (restart == 'y') ;
- System.out.println("Merci au revoir");
- read.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement