I am having a problem with this project I am working on. The assignment is to create an application that will give a user the choice of displaying the roman numeral equivalence of a number between 1 and 10 or displaying a count of roman numerals from 1 to 10.

program should not end before the user decides to end it
must use the if, while, for and switch structures in code
and output format should resemble:

"This program can display any roman # between 1 and 10.
This program can also count from 1 to 10 in roman #

enter the # 1 to display the roman equivalent of a number
enter #2 to count from 1 to 10 in roman numerals
enter any other # to end application

enter ur choice.... 1

enter any # from 1 to 10: 7

roman numeral VII Decimal 7

and it should loop back to enter 1 or 2 options

than enter ur choice 2

it should list roman numeral I-X and decimal 1-10 but in 2 separate rows.

This is what i have so far but I'm stuck. My first if statement keeps looping and i just cant think of what i should do for the second part. Help would be greatly appreciated.

#include <stdio.h>

int main( void )
{
	int choice;
	int num;
     
	
	printf("This program can display any Roman numeral between 1 and 10.\n");
	printf("This program can also count from 1 to 10 in Roman numeral.\n\n");



	printf("Enter the number 1 to display the Roman equivelent of a number.\n");
	printf("Enter the number 2 to count from 1 to 10 in Roman numerals.\n");
	printf("Enter any other number to end the application.\n\n");

	printf("Enter your choice.\n");
	scanf("%d\n", &choice);

	while ( choice == 1 || choice == 2 )

		if ( choice == 1 ){
			printf( "enter any number from 1 to 10\n" );
			scanf( "%d\n", &num );

			switch ( num ){

				case '1':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "I"  );
					break;

				case '2':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "II"  );
					break;

				case '3':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "III"  );
					break;

				case '4':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "IV"  );
					break;

				case '5':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "V"  );
					break;

				case '6':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "VI"  );
					break;

				case '7':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "VII"  );
					break;

				case '8':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "VIII"  );
					break;

				case '9':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "IX"  );
					break;

				case '10':
					printf( "%s%s\n", "Roman\n Numeral", "Decimal");
					printf( "%s\n" , "X"  );
					break;

			}
		}
		
	        if ( choice == 2 )

			for ( num = 1; num <= 10; num++)
				printf( "%s%s\n", "Roman\n Numeral", "Decimal");
				

	return 0;

		}

In your while loop, you never change the choice variable to something else then 1.
It is testing for choice==1 or choice==2 so it will keep looping forever.

Okay I edited my code and now the first part works correctly except the user has to input 1 twice before it prompts the user to enter number to convert and no matter what number the user inputs its only showing conversion for the number 1. Also I am having a block on how to start part two. Heres new code

#include <stdio.h>

int main( void )
{
    int choice;
    int num;

    do{
    printf("This program can display any Roman numeral between 1 and 10.\n");
    printf("This program can also count from 1 to 10 in Roman numeral.\n\n");



    printf("Enter the number 1 to display the Roman equivelent of a number.\n");
    printf("Enter the number 2 to count from 1 to 10 in Roman numerals.\n");
    printf("Enter any other number to end the application.\n\n");

    printf("Enter your choice:");
    scanf("%d\n", &choice);



        if ( choice == 1 ){
            printf( "enter any number from 1 to 10\n" );
            scanf( "%d\n", &num );

            switch ( num ){

                case 1:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "I", "1"  );
                    break;

                case 2:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "II", "2"  );
                    break;

                case 3:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "III","3" );
                    break;

                case 4:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "IV", "4"  );
                    break;

                case 5:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "V","5"  );
                    break;

                case 6:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "VI","6"  );
                    break;

                case 7:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "VII", "7"  );
                    break;

                case 8:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "VIII","8"  );
                    break;

                case 9:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "IX", "9"  );
                    break;

                case 10:
                    printf( "%7s%21s\n", "Roman\nNumeral", "Decimal");
                    printf( "%1s%21s\n" , "X","10" );
                    break;


            }
        }



            if ( choice == 2 )

            for ( num = 1; num <= 10; num++)
                printf( "%s%s\n", "Roman\n Numeral", "Decimal");
    }   while ( choice == 1 || choice == 2 );
            return 0;

        }

Edited 3 Years Ago by Dani: Formatting fixed

set choice to 3 before the while-loop
do the scanf in the
while loop
1--func 1
2--func 2
3--quit the while loop , do something like while (choice != 3) etc.

This question has already been answered. Start a new discussion instead.