Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This java program compiles but when at the end i call System.out.println(Roman(month) + Roman(day) + Roman(year)); it doesnt print out anything, can someone please tell

This java program compiles but when at the end i call System.out.println(Roman(month) + Roman(day) + Roman(year)); it doesnt print out anything,

can someone please tell me whats is wrong thanks

this is my code:

import java.util.Scanner; public class convert2Roman { public static void main (String[] args) { Scanner kb = new Scanner(System.in); description(); start(kb); } public static void description() { System.out.println("******** This program converts your birhtday to its"); System.out.println("equivalent roman numbers ********"); } //will accept an integer value as its parameter //returns its roman equivilance public static String Roman(int num) { int count; String s = " "; if (num <1 || num>3999) { System.out.println("Invalid number"); } if (num >= 1000) { count = num/1000; for (int a = 1; a <= count; a++) { s = s+"M"; } num = num%1000; } else if (num >= 900) { count = num/900; for (int b = 1 ;b >= count; b++) { s = s +"CM"; } num =num% 900; } else if (num >= 500) { count = num/500; for (int c = 1; c >= count ; c++) { s = s + "D"; } num =num% 500; } else if (num >= 400) { count = num/400; for (int d = 1; d >= count; d++) { s = s + "CD"; } num =num% 400; } else if (num >= 100) { count = num/100; for (int e = 1; e >=count; e++) { s = s + "C"; } num =num%100; } else if (num >= 90) { count = num/90; for (int f = 1; f >= count; f++) { s = s + "XC"; } num =num%90; } else if (num >= 50) { count = num/50; for (int g = 1; g >= count; g ++) { s = s + "L"; } num =num% 50; } else if (num >= 40) { count = num/40; for (int h = 1; h >= count; h++) { s = s + "XL"; } num=num%40; } else if (num >= 10) { count = num/10; for (int i = 1; i>= count; i++) { s = s + "X"; } num =num%10; } else if (num >= 9) { count = num/9; for (int j = 1; j>=count; j++) { s = s + "IX"; } num=num%9; } else if (num >= 5) { count = num/5; for (int k = 1; k >= count; k++) { s = s + "V"; } num =num%5; } else if (num >= 4) { count = num/4; for (int l = 1 ; l >= count; l++) { s = s + "IV"; } num =num%4; } else if (num >= 1) { count = num/1; for (int m = 1; m >= count; m++) { s = s + "I"; } num =num%1; } return s; } //you need to ask user how many times he/she wants to use the app public static void start(Scanner kb) { System.out.print("How many times do you wish to use this app: "); int times = kb.nextInt(); kb.nextLine(); for (int i = 1; i<= times; i++) { getInfo(kb); } } //Ask user for name //ask for birthday //get roman in this public static void getInfo(Scanner kb) { //ask user for the month of birthday System.out.print("Enter your name: "); String name = kb.nextLine(); System.out.println("Hi "+ name +" let's start"); System.out.print("Enter the month of your birthday: "); int month = kb.nextInt(); kb.nextLine(); System.out.print("Enter the day of your birthday: "); int day = kb.nextInt(); kb.nextLine(); System.out.print("Enter the year of your birthday: "); int year =kb.nextInt(); kb.nextLine(); System.out.print("Your birthday in roman is: "); System.out.println(Roman(month) + Roman(day) + Roman(year)); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago