1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zloy xaker [14]
2 years ago
15

Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even and how many of

them are odd.
Computers and Technology
1 answer:
Anvisha [2.4K]2 years ago
8 0

Answer:

import random

numbers = []

even = 0

odd = 0

for i in range(100):

   numbers.append(random.randint(1, 200))

for i in range(100):

   if numbers[i] % 2 == 0:

       even += 1

   else:

       odd += 1

print("Even:", even)

print("Odd:", odd)

Explanation:

Gg ez.

You might be interested in
2) [13 points] You’ve been hired by Banker Bisons to write a C++ console application that determines the number of months to rep
Paha777 [63]

Answer:

Check the explanation

Explanation:

CODE:

#include <iostream>

#include <iomanip>

using namespace std;

double getLoanAmount() { // functions as per asked in question

double loan;

while(true){ // while loop is used to re prompt

cout << "Enter the car loan amount ($2,500-7,500): ";

cin >> loan;

if (loan>=2500 && loan <= 7500){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< loan << " is an invalid loan amount." << endl;

}

}

return loan;

}

double getMonthlyPayment(){ // functions as per asked in question

double monthpay;

while(true){ // while loop is used to re prompt

cout << "Enter the monthly payment ($50-750): ";

cin >> monthpay;

if (monthpay>=50 && monthpay <= 750){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< monthpay << " is an invalid monthly payment." << endl;

}

}

return monthpay;

}

double getInterestRate(){ // functions as per asked in question

double rate;

while(true){ // while loop is used to re prompt

cout << "Enter the annual interest rate (1-6%): ";

cin >> rate;

if (rate>=1 && rate <= 6){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: "<< rate << "% is an invalid annual interest rate." << endl;

}

}

return rate;

}

int main() {

cout << setprecision(2) << fixed; // to print with 2 decimal places

int month = 0; // initializing month

// calling functions and storing the returned value

double balance= getLoanAmount();

double payment= getMonthlyPayment();

double rate= getInterestRate();

rate = rate /12 /100; // as per question

// printing as per required in question

cout << "Month Balance($) Payment($) Interest($) Principal($)"<< endl;

while(balance>0){ // while the balance is more than zero

month = month + 1; // counting Months

// calculations as per questions

double interest = balance * rate;

double principal = payment - interest;

balance = balance - principal;

// printing required info with proper spacing

cout <<" "<< month;

cout <<" "<< balance;

cout <<" "<< payment;

cout <<" "<< interest;

cout <<" "<< principal << endl;

}

cout << "Months to repay loan: " << month << endl; // displaying month

cout << "End of Banker Bisons";

Kindly check the output in the attached image below.

5 0
3 years ago
A company ABC asked you to design a simple payroll program that calculates and employee's weekly gross pay, including any overti
julsineya [31]

Answer:

<em>C++.</em>

#include <iostream>

using namespace std;

////////////////////////////////////////////////////////////////

int main() {

   int weekly_hours = 0;

   int hourly_rate;

   float gross_pay = 0;

   cout<<"Enter weekly hours worked: ";

   cin>>weekly_hours;

   

   cout<<"Enter hourly rate: ";

   cin>>hourly_rate;

   

   cout<<endl;

   ////////////////////////////////////////////////

   if (weekly_hours > 40) {

       gross_pay = (weekly_hours*hourly_rate) + ((weekly_hours*hourly_rate)*0.5);

   }

   else

       gross_pay = weekly_hours*hourly_rate;

       

   cout<<"Weekly gross pay: $"<<gross_pay;

   ////////////////////////////////////////////////

   return 0;

}

3 0
2 years ago
What are two distinctive types of unmanned aircraft systems
chubhunter [2.5K]
Probes and Drones
Hope this helps and please give brainliest!
8 0
3 years ago
What feature is not included in most DTP programs?
IceJOKER [234]
Features included in most DTP programs would be kerning, master pages, and WYSIWYG. S video editing isn't included in most programs for DTP
5 0
3 years ago
You received an email from someone who claims to be a representative from your school. The email asked you to click on a link to
Sergeeva-Olga [200]

Answer:

Phishing

Explanation:

Phishing = Link to a site, usually a fake replica of a legitimate site but with added implements that can be used to spy on you (how people become victims of identity theft

6 0
3 years ago
Other questions:
  • System software falls into two categories: operating system software and ____ programs.â
    13·1 answer
  • Assume that name has been declared suitably for storing names (like "amy" , "fritz" and "moustafa") write some code that reads a
    5·1 answer
  • Most keyboards today are in a
    8·1 answer
  • Which of the following illustrates an example of a Boolean data type?
    15·1 answer
  • NEED HELP NOW 25 POINTS WILL MARK BRAINLIEST!!!!!!!
    8·1 answer
  • What should be a technicians first step in an A/C system
    7·1 answer
  • When you ____ an exception, you send a message that an error has occurred to another part of the program.
    7·2 answers
  • How is data written to a blockchain?
    10·1 answer
  • ¿Por qué disminuyó el tamaño de la población de caribús? Usa la evidencia inicial para explicar por qué disminuyó el tamaño de l
    5·1 answer
  • Which of the following helps you plan out every step of an animation?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!