Photo AI
Question 1
An applicant must complete an application form to obtain a loyalty card. Do the following: - Compile and execute the program found in the Question1 folder. The use... show full transcript
Step 1
Answer
To validate the information entered by the user, begin by extracting the name and surname from the input text box. Check for the presence of at least one space to determine if multiple names are included. If no space is found, a dialog box should display the message:
"The name-surname field does not contain a space."
Next, extract the ID number. If it is empty, display the message:
"An ID number must be entered."
If the ID number is entered but does not meet the requirement of 13 digits, display the message:
"The ID number does not consist of 13 digits."
If both fields are valid, update the visibility of the welcoming message label to reflect this with the message:
"Welcome to our loyalty card program!"
Step 2
Answer
In this section, the user is required to enter the final amount of their purchase. The program should extract this amount from the text box and convert it into a real value (number) for processing.
Utilize conditional statements (Case/Switch or If) to check the type of loyalty card selected. If the card is of type DI (Immediate Discount), compute the discount by calculating 1.5% of the entered amount:
This calculated discount needs to be displayed as currency with two decimal places.
If the card is of type CH (Donation towards charity), calculate the amount to be donated:
Step 3
Answer
The completion of the loyalty card number requires compiling several parts. Start with Part 1, which is comprised of:
For Part 2, access the last digit of the ID number and concatenate it with the appropriate character from the predefined string charString that corresponds to that last digit's value.
Lastly, Part 3 must reflect the loyalty card type determined earlier (DI or CH) in the respective section. Combine these components to form a complete loyalty card number that adheres to the specified format.
Report Improved Results
Recommend to friends
Students Supported
Questions answered