0% found this document useful (0 votes)
1 views

Conditional Statements Homeworks

The document outlines a series of programming tasks involving conditional statements, focusing on sports outcomes and performance ratings. It includes programs for determining match results, player performance, loan eligibility, tax calculations, and a menu-driven calculator. Each task is presented with a structured solution, demonstrating the use of conditional logic in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Conditional Statements Homeworks

The document outlines a series of programming tasks involving conditional statements, focusing on sports outcomes and performance ratings. It includes programs for determining match results, player performance, loan eligibility, tax calculations, and a menu-driven calculator. Each task is presented with a structured solution, demonstrating the use of conditional logic in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Conditional Statements Related Problems

1. Write a program to determine the outcome of a football match by taking the number of goals
scored by two teams. If Team A scores more goals, print "Team A Wins", if Team B scores
more goals, print "Team B Wins", and if the scores are equal, print "Draw".
2. Create a program that rates a football player's performance based on the number of goals
scored in a season. If the player scores 0 goals, print "Poor Performance", between 1 and 5
goals, print "Average Performance", between 6 and 15 goals, print "Good Performance", and
more than 15 goals, print "Excellent Performance".
3. Write a program that takes match results (Win, Draw, Loss) for two teams in a group stage,
calculates their points based on wins, draws, and losses, and prints the top two teams
qualifying for the knockout stage.
4. Create a program to rate a cricket player's performance based on the number of runs scored in
a match. If the player scores less than 30 runs, print "Low Performance", between 30 and 60
runs, print "Medium Performance", and more than 60 runs, print "High Performance".
5. Write a program that calculates the result of a cricket match by taking the runs scored by two
teams. Print "Team A wins by X runs", "Team B wins by X runs", or "Match Drawn" based on
the comparison of the scores.
6. Write a program that calculates the batting average of a cricket player by taking the number of
innings, total runs scored, and number of times out. If the player was never out, print "Batting
Average Not Available"; otherwise, calculate and print the batting average as (Total Runs /
Times Out).
7. Create a program that takes a traffic light color input (Red, Yellow, or Green) and outputs the
corresponding action— “Stop” for Red, “Prepare to stop” for Yellow, and “Go” for Green. If
the input is invalid, print "Invalid color!".
8. A program that checks if a person qualifies for a personal loan with the following conditions:
age between 25 and 50, monthly income over $4000, no active loans, and a credit score
higher than 700. If they meet the criteria, print "Eligible for loan". If their credit score is
between 650 and 700, print "Eligible for loan with co-signer". Otherwise, print "Not eligible
for loan".
9. Write a program that calculates tax based on annual income, using different tax rates: 5% for
income under $20,000, 10% for income between $20,000 and $50,000, 15% for income
between $50,000 and $100,000, and 20% for income above $100,000. The program should
calculate and display the appropriate tax.
10. Implement a menu-driven calculator program that allows users to perform four operations:
addition, subtraction, multiplication, and division. The program should repeatedly display a
menu until the user selects "Exit". The operations should be performed based on user input
using a switch-case structure.
11. Create an ATM simulation program with options to check balance, deposit money, withdraw
money, and exit. The program should ask for a PIN, verify it, and allow the user to perform
actions. Ensure the balance doesn’t go negative and handle invalid choices appropriately.
12. Write a program that prompts the user to input a number (1–7) and prints the corresponding
day of the week (Monday to Sunday). The program should validate the input and prompt the
user again if the number is invalid, ensuring the input is between 1 and 7.
Solution
1.

Start

Input goalsA

Input goalsB

if goalsA > goalsB

Print "Team A Wins"

else if goalsA < goalsB

Print "Team B Wins"

else

Print "Draw"

End

2.

Start

Input goals

if goals == 0

Print "Poor Performance"

else if goals >= 1 and goals <= 5

Print "Average Performance"

else if goals >= 6 and goals <= 15

Print "Good Performance"

else if goals > 15

Print "Excellent Performance"

End
3.

Start

Input resultsA // Win, Draw, Loss

Input resultsB // Win, Draw, Loss

pointsA = 0

pointsB = 0

if resultsA == "Win"

pointsA = pointsA + 3

else if resultsA == "Draw"

pointsA = pointsA + 1

if resultsB == "Win"

pointsB = pointsB + 3

else if resultsB == "Draw"

pointsB = pointsB + 1

if pointsA > pointsB

Print "Team A qualifies"

else if pointsB > pointsA

Print "Team B qualifies"

else

Print "Draw, check tie-breaker"

End
4.

Start

Input runs

if runs < 30

Print "Low Performance"

else if runs >= 30 and runs <= 60

Print "Medium Performance"

else if runs > 60

Print "High Performance"

End

5.

Start

Input runsA

Input runsB

if runsA > runsB

Print "Team A wins by " + (runsA - runsB) + " runs"

else if runsA < runsB

Print "Team B wins by " + (runsB - runsA) + " runs"

else

Print "Match Drawn"

End

You might also like