🔒 Closed Number to roman numeral

Status
Not open for further replies.

meta29

Enthusiast
Code:
import java.util.Scanner;
class loop{
  loop(){
    System.out.println("-- convertion is online --");
  }
  String [] ones = {"","I","II","III","IV","V", "VI","VII","VIII","IX","X","L","C","D","M"};



  void noloop (int value){
   
      System.out.print(ones[value]);
     
  }

  void loop (int value,int loop){
   
    for (int i = 0; i < loop; i++){
     
      System.out.print(ones[value]);
    }
   
  }




}
public class Insertionsort {

  public static void main(String[] args) {
  Scanner input = new Scanner (System.in);
   loop get = new loop ();
  System.out.print("Enter Number 1 - 3000: ");
  int x = input.nextInt();

  System.out.print("Converted value: ");

for(int i = 0; i < 3; i++){

  if(x<=10){
    get.noloop(x);
    break;
  }else if(x<40){
    get.loop(10,x/10);
    get.noloop(x%10);
    System.out.print(" ");
    break;
  }else if(x<50){
    get.noloop(10);
    get.noloop(11);
    get.noloop(x%10);
    System.out.print(" ");
    break;
  }else if(x<90){
    get.noloop(11);
    get.loop(10,(x-50)/10);
    get.noloop(x%10);
    System.out.print(" ");
    break;
  }else if(x<100){
    get.noloop(10);
    get.noloop(12);
    get.noloop(x%10);
    System.out.print(" ");
    break;
  }else if (x<400){
    get.loop(12,x/100);
    x =   x %100;
    System.out.print(" ");
  }else if(x<500){
    get.noloop(12);
    get.noloop(13);
    x = x % 100;
    System.out.print(" ");
  }else if(x<900){
    get.noloop(13);
    x = x - 500;
  }else if(x<1000){
    get.noloop(12);
    get.noloop(14);
    x = x - 900;
    System.out.print(" ");
  }else if (x<= 3000){
    get.loop(14,x/1000);
    x = x % 1000;
    System.out.print(" ");
  }

}


  }

}

nshot_20200414_165904_com.duy.compiler.javanide.md.webp
 
hirap intindihin ng java siguro kais python pa lang ginagamit ko

Java = Python

void = def
if (condition){code} = if condition:code
else if(condition){code} = elif contdition:code
System.out.println("text") = print("text")
scanner.nextint() = input("enter number")

Syntax lang binago lods, hehehe
 
Ts lagay ka pi ng nga comment para sa mga newbie para mapag aralan kung pano gumana at kung para sa ba yung line na ganito ganyan. Btw salamat po dito ts.
 
Status
Not open for further replies.

About this Thread

  • 8
    Replies
  • 525
    Views
  • 5
    Participants
Last reply from:
meta29

Trending Topics

Online now

Members online
1,209
Guests online
1,767
Total visitors
2,976

Forum statistics

Threads
2,291,450
Posts
29,070,871
Members
1,210,881
Latest member
cobeeee
Back
Top