0% found this document useful (0 votes)
8 views2 pages

AP CS A Free Response Questions 50

The document contains a list of programming exercises for AP Computer Science A, focusing on various Java concepts such as variable declaration, control structures, loops, and mathematical operations. Each exercise is designed to reinforce fundamental programming skills, including data type conversions, conditional statements, and string manipulation. The tasks range from basic operations to more complex algorithms, providing a comprehensive practice resource for students.

Uploaded by

cacikalin26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

AP CS A Free Response Questions 50

The document contains a list of programming exercises for AP Computer Science A, focusing on various Java concepts such as variable declaration, control structures, loops, and mathematical operations. Each exercise is designed to reinforce fundamental programming skills, including data type conversions, conditional statements, and string manipulation. The tasks range from basic operations to more complex algorithms, providing a comprehensive practice resource for students.

Uploaded by

cacikalin26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

AP Computer Science A - Free Response Questions

1. Create an int variable with value 100 and assign it to a double variable, then print it.

2. Create a double variable with value 12.99, convert it to int, and print it.

3. Declare two int variables (35 and 8). Perform addition, subtraction, multiplication, and division.

4. Create a boolean variable with value true and print it.

5. Define a final variable for GRAVITY (9.8) and use it to calculate force (Force = Mass * Gravity).

6. Declare a String with "Learning Java" and print its length.

7. Declare a String with "Object-Oriented Programming" and print the index of "Programming".

8. Compare "grape" and "melon" using compareTo() and print which comes first alphabetically.

9. Declare a double with 49.0 and print its square root using Math.sqrt().

10. Declare a double with -3.14 and print its absolute value using Math.abs().

11. Declare an int variable with value 25. If greater than 20, print "Big number", else print "Small
number".

12. Create a boolean variable isWeekend = false. Print "Relaxing day" if true, otherwise "Work time".

13. Store a student grade as an int. Print "Excellent" for 90+, "Good" for 70+, otherwise "Needs
improvement".

14. Declare a boolean variable isRaining = false. Print "It's a sunny day" if not raining.

15. Declare an int variable with a random value. Print "Medium range" if between 50 and 100.

16. Use a for loop to count backward from 10 to 1 and print the numbers.

17. Use a while loop to print "Keep Coding!" seven times.

18. Declare an int with value 5 and use a while loop to increase it up to 20, printing each value.

19. Use nested for loops to print a 5x5 star (*) matrix.

20. Use a for loop to print numbers from 1 to 15 but only display up to 10.

21. Declare two int variables. If one is divisible by the other, print "Divisible".

22. Create a double variable with 2.718 and convert it to int before printing.

23. Declare an int variable with a random value. Print "Even" if even, otherwise "Odd".

24. Use a for loop to print even numbers from 1 to 20.

25. Use a while loop to repeatedly prompt a user for correct input until it's valid.

26. Declare an int variable and print its square.


27. Declare a String variable with "Software Engineering" and check if it contains "Engineering".

28. Write an if-else statement to determine if a number is positive, negative, or zero.

29. Use a for loop to calculate the sum of numbers from 1 to 50.

30. Use a while loop to calculate the factorial of a given number.

31. Write an if-else statement to check if a year is a leap year.

32. Use a for loop to print the squares of numbers from 1 to 10.

33. Write an if statement to check if a number is prime.

34. Use a for loop to print a right-angled triangle pattern with * symbols.

35. Declare a String variable with "Java is powerful" and find the index of "powerful".

36. Declare an int variable and print its cube.

37. Use a while loop to print odd numbers from 1 to 25.

38. Write an if-else statement to compare three numbers and print the largest.

39. Declare two int variables and swap their values without using a third variable.

40. Use a for loop to print Fibonacci series up to 10 terms.

41. Write an if-else statement to classify a triangle based on three given sides.

42. Declare a String variable with "Hello World!" and replace "World" with "Java".

43. Use a for loop to find the largest element in an array of integers.

44. Declare an int variable and print whether it is a multiple of 3 and 5.

45. Use a nested for loop to print a multiplication table from 1 to 5.

46. Declare a boolean variable and toggle its value.

47. Write an if-else statement to determine if a number is between 10 and 100.

48. Use a for loop to reverse a given String.

49. Declare an int variable and print whether it is a perfect square.

50. Write an if-else statement to check if a number is a palindrome.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy