Header Ads

[If...else] Exercises without implementation

  1. Write a program that prompts the user to enter an integer and then checks if it is positive, negative, or zero.
  2. Write a program that prompts the user to enter a number and then checks if it is a multiple of 3.
  3. Write a program that prompts the user to enter two integers and then checks if the first integer is a multiple of the second integer.
  4. Write a program that prompts the user to enter a year and then checks if it is a leap year.
  5. Write a program that prompts the user to enter a character and then checks if it is a letter.
  6. Write a program that prompts the user to enter a number and then checks if it is prime.
  7. Write a program that prompts the user to enter a string and then checks if it is a palindrome.
  8. Write a program that prompts the user to enter three numbers and then checks if the sum of any two of them is equal to the third.
  9. Write a program that prompts the user to enter an integer and then checks if it is even or odd.
  10. Write a program that prompts the user to enter a number and then checks if it is a perfect square.
  11. Write a program that prompts the user to enter a character and then checks if it is a digit.
  12. Write a program that prompts the user to enter a string and then checks if it is a palindrome ignoring case.
  13. Write a program that prompts the user to enter three numbers and then checks if they form a Pythagorean triple (a^2 + b^2 = c^2).
  14. Write a program that prompts the user to enter two integers and then checks if their sum is even.
  15. Write a program that prompts the user to enter a number and then checks if it is a power of two.
  16. Write a program that prompts the user to enter two characters and then checks if they are both uppercase letters.
  17. Write a program that prompts the user to enter a string and then checks if it contains the word "Java".
  18. Write a program that prompts the user to enter a number and then checks if it is a perfect number (the sum of its divisors equals the number itself).
  19. Write a program that prompts the user to enter a year and then checks if it is a leap year using the Gregorian calendar rule.
  20. Write a program that prompts the user to enter a number and then checks if it is a Fibonacci number.
  21. Write a program that prompts the user to enter a string and then checks if it is a pangram (contains every letter of the alphabet).
  22. Write a program that prompts the user to enter a year, month, and day, and then checks if the date is valid.
  23. Write a program that prompts the user to enter a number and then checks if it is a narcissistic number (the sum of its digits raised to the power of the number of digits equals the number itself).
  24. Write a program that prompts the user to enter three integers and then checks if they form a Pythagorean triple in any order (a^2 + b^2 = c^2).
  25. Write a program that prompts the user to enter a string and then checks if it is a palindrome ignoring punctuation and spaces.
  26. Write a program that prompts the user to enter a number and then checks if it is a perfect cube.
  27. Write a program that prompts the user to enter a number and then checks if it is a Kaprekar number (a number whose square can be split into two parts that add up to the original number).
  28. Write a program that prompts the user to enter two strings and then checks if they are anagrams (contain the same letters in the same frequency).
  29. Write a program that prompts the user to enter a number and then checks if it is a Harshad number (a number that is divisible by the sum of its digits).
  30. Write a program that prompts the user to enter a string and then checks if it is a valid ISBN-10 (International Standard Book Number).
  31. Write a program that prompts the user to enter a number between 1 and 7 and then prints the corresponding day of the week.
  32. Write a program that prompts the user to enter a letter grade (A, B, C, D, or F) and then prints the corresponding GPA value.
  33. Write a program that prompts the user to enter a month (1-12) and then prints the number of days in that month.
  34. Write a program that prompts the user to enter a shape (circle, square, or triangle) and then prints the area of that shape.
  35. Write a program that prompts the user to enter a color (red, green, or blue) and then prints the corresponding RGB values.
  36. Write a program that prompts the user to enter a number (1-12) and then prints the corresponding name of the zodiac sign.
  37. Write a program that prompts the user to enter a temperature in Celsius or Fahrenheit and then converts it to the other unit.
  38. Write a program that prompts the user to enter a month (1-12) and then prints the corresponding name of the season (winter, spring, summer, or fall).
  39. Write a program that prompts the user to enter a fruit (apple, banana, or orange) and then prints the corresponding price per pound.
  40. Write a program that prompts the user to enter a number (1-5) and then prints the corresponding emoji (smile, heart, star, lightning bolt, or skull).
Nguồn: chatGPT

Không có nhận xét nào

Được tạo bởi Blogger.