Sure! I can help you with that.
To solve this problem, you can use if-else statements and conditions to check the validity of the inputted pocket money and determine whether it ends with 7.
Here's a possible solution in C language:
C:
#include <stdio.h>
int main() {
int pocketMoney;
printf("Enter current pocket money: ");
scanf("%d", &pocketMoney);
if (pocketMoney >= 0) {
printf("%d\n", pocketMoney);
if (pocketMoney % 10 == 7) {
printf("Such lucky money!\n");
} else {
printf("Just normal money.\n");
}
} else {
printf("Stop lying, tell me what's in your pocket!\n");
}
return 0;
}
In this solution, we first prompt the user to enter their current pocket money. Then, we use if-else statements and conditions to check if the pocket money is valid (non-negative) and whether it ends with 7. If the pocket money is valid, we print the amount, and if it ends with 7, we print "Such lucky money!", otherwise, we print "Just normal money.". If the pocket money is negative, we print "Stop lying, tell me what's in your pocket!".
I hope this helps! Let me know if you have any further questions.
Sure! Here's a solution in C language to solve the "Ask the Pocket Money" problem:
C:
#include <stdio.h>
int main() {
int pocketMoney;
printf("Enter current pocket money: ");
scanf("%d", &pocketMoney);
if (pocketMoney >= 0) {
printf("%d\n", pocketMoney);
if (pocketMoney % 10 == 7) {
printf("Such lucky money!\n");
} else {
printf("Just normal money.\n");
}
} else {
printf("Stop lying, tell me what's in your pocket!\n");
}
return 0;
}
In this solution, we first prompt the user to input their current pocket money. We then use an if-else statement to check if the pocket money is greater than or equal to 0 (non-negative). If it is, we print the amount.
Next, we use another if-else statement to check if the pocket money ends with 7. We do this by checking if the remainder of dividing the pocket money by 10 is equal to 7. If it is, we print "Such lucky money!". Otherwise, we print "Just normal money.".
If the pocket money is negative, we print "Stop lying, tell me what's in your pocket!".
I hope this helps! Let me know if you have any further questions.