Pseudo Code Generator

Number Translator for French and German

This pseudo code outlines a program that translates numbers from 1 to 30 into French or German. Users input a number and select a language to receive the corresponding translation, with input validation for range and type.


Empty image or helper icon

Prompt

var frenchNumbers = ["un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf", "vingt", "vingt et un", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", "vingt-sept", "vingt-huit", "vingt-neuf", "trente"]
var germanNumbers = ["eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn", "zwanzig", "einundzwanzig", "zweiundzwanzig", "dreiundzwanzig", "vierundzwanzig", "fünfundzwanzig", "sechsundzwanzig", "siebenundzwanzig", "achtundzwanzig", "neunundzwanzig", "dreißig"]
var userNumber = (prompt("enter a number between 1 and 30:"))
if (userNumber < 1 || userNumber > 30 ) {
    alert("Please enter a number between 1 and 30") ;
}
if (userNumber != parseInt(userNumber)) {
    alert("please enter and integer")
}
var userLangauge = prompt("enter a language either French or German:")

if (userLangauge == "French") {
    translatedWord = frenchNumbers [userNumber - 1]
} if (userLangauge == "German" ) {
    translatedWord = germanNumbers [userNumber - 1]
} 
alert("The translation is: " +translatedWord)

Answer

Pseudo Code for Translating Numbers into French or German

Objective

The goal is to allow a user to input a number between 1 and 30 and select a language (French or German) to receive the corresponding word for that number.

Variables

  • frenchNumbers: Array containing French words for numbers 1 to 30.
  • germanNumbers: Array containing German words for numbers 1 to 30.
  • userNumber: User's input number.
  • userLanguage: User's selected language (French or German).
  • translatedWord: The translated word corresponding to the user's input.

Pseudo Code

BEGIN

    // Initialize arrays for number translations
    SET frenchNumbers = ["un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf", "vingt", "vingt et un", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", "vingt-sept", "vingt-huit", "vingt-neuf", "trente"]
    SET germanNumbers = ["eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn", "zwanzig", "einundzwanzig", "zweiundzwanzig", "dreiundzwanzig", "vierundzwanzig", "fünfundzwanzig", "sechsundzwanzig", "siebenundzwanzig", "achtundzwanzig", "neunundzwanzig", "dreißig"]

    // Prompt user for a number
    SET userNumber = PROMPT("Enter a number between 1 and 30:")

    // Check if userNumber is within the valid range
    IF (userNumber < 1 OR userNumber > 30) THEN
        ALERT("Please enter a number between 1 and 30")
        EXIT

    // Check if userNumber is an integer
    IF (userNumber is not an integer) THEN
        ALERT("Please enter an integer")
        EXIT

    // Prompt user for desired language
    SET userLanguage = PROMPT("Enter a language: either French or German:")

    // Determine the translated word based on the chosen language
    IF (userLanguage == "French") THEN
        SET translatedWord = frenchNumbers[userNumber - 1]
    ELSE IF (userLanguage == "German") THEN
        SET translatedWord = germanNumbers[userNumber - 1]

    // Display the translation
    ALERT("The translation is: " + translatedWord)

END

Summary of Logic

  1. Initialize arrays for French and German number translations.
  2. Prompt the user for a number between 1 and 30.
  3. Validate the input number to ensure it is within the specified range and is an integer.
  4. Ask the user to specify a language.
  5. Fetch the corresponding translated word based on the selected language and user number.
  6. Display the translated word to the user.

This pseudo code serves as a foundational guide for implementing the required functionality in a programming environment.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This pseudo code outlines a program that translates numbers from 1 to 30 into French or German. Users input a number and select a language to receive the corresponding translation, with input validation for range and type.