answer.
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
pogonyaev
28 days ago
9

Assume a machine during its initial testing phase produces 10 widgets a day. After 10 days of testing (starting on day 11), it b

egins to run at full speed, producing 40 widgets a day. After 50 days at full speed (days 11-60), it gradually starts becoming less productive, and produces 1 fewer widget per day, (ie. 39 widgets on day 61, etc.) until on day 100 it no longer produces any widgets.
Required:
Write a program that will read in a day number from the keyboard and will report the total number of widgets produced from the initial testing phase up to and including the day entered. For example, entering 3 would report 30 widgets.
Computers and Technology
1 answer:
Harlamova29_29 [932]28 days ago
4 0

Response:

Python Code:

n = int(input("Days: "))

total = 0

for i in range(1,n+1):

     if i <= 10:

           total += 10

     elif i <= 60:

           total += 40

     elif i <= 99:

           total += 100 - i

print(str(total)+ " widgets")

Clarification:

This line requests user input for the number of days.

n = int(input("Days: "))

This line sets the initial total number of widgets to zero.

total = 0

The subsequent loop calculates total widgets based on the established rules.

for i in range(1,n+1):

     if i <= 10: -> Applies when days are 10 or fewer

           total += 10

     elif i <= 60: -> Applies when days are between 11 and 60

           total += 40

     elif i <= 99: -> Applies when days are under 100

           total += 100 - i

This line outputs the total count.

print(str(total)+ " widgets")

You might be interested in
Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input.
Amiraneli [921]

Answer:

In C++:

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

int main(){

   string lname, fname, stringnum;    int num; string login, pwd;

   cout<<"Last Name: ";    cin>>lname;

   cout<<"First Name: ";    cin>>fname;

   cout<<"Four-digit integer: ";    cin>>num;

   stringnum = to_string(num).substr(0, 4);

   stringstream geek(stringnum);    geek>>num;

   num = num%100;

   pwd = to_string(num);

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

   cout<<"Login Name: "<<login<<endl;

   cout<<"Password: "<<pwd<<endl;

   return 0;

}

Explanation:

This initializes all the required variables

   string lname, fname, stringnum;    int num;     string login, pwd;

This asks the user for their last name

   cout<<"Last Name: ";    cin>>lname;

This asks for the first name of the user

   cout<<"First Name: ";    cin>>fname;

This prompts for a four-digit number

   cout<<"Four-digit integer: ";    cin>>num;

This converts the number into a string and extracts the first four digits

   stringnum = to_string(num).substr(0, 4);

This changes the string back into an integer

   stringstream geek(stringnum);    geek>>num;

This extracts the last two digits of the four-digit number

   num = num%100;

This generates the user's password

  pwd = to_string(num);

This constructs the user's login name.

This block runs if the last name has fewer than five letters

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

This block runs otherwise

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

This displays the login name

   cout<<"Login Name: "<<login<<endl;

This displays the password

   cout<<"Password: "<<pwd<<endl;

3 0
1 month ago
Find true or false. A hacker is hacking software with access in sensitive information from your computer​
Harlamova29_29 [932]
IT'S CORRECT!! I LOOKED IT UP
7 0
20 days ago
FOREACH, EXPLODE and MAIL are examples of crazy functions.
zubka84 [945]
The selected response is B
4 0
1 month ago
To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’
amid [805]

Answer:

// here's the Java code.

import java.util.*;

// definition of the class

class BookstoreCredit

{

/* method that prints a message including the name and grade point */

   public static void fun(String name,double grade)

   {

// multiplying grade by 10

       grade=grade*10;

// display the message

       System.out.println(name+"\'s average grade is $"+grade);

   }

// main method for the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner instance to read input

       Scanner s=new Scanner(System.in);

        // declaring variables

      String s_name;

      double grade;

      System.out.print("Please enter the name:");

      s_name=s.nextLine();

      System.out.print("Please enter the grade point:");

      grade=s.nextDouble();

   }catch(Exception ex){

       return;}

}

}

Explanation:

Define a string variable named s_name and a double variable named grade. Obtain the name and grade from the user, then invoke the fun() method with these parameters, which will multiply the grade by 10 and output a message that includes the student's name along with their average grade.

Output:

Please enter the name:john

Please enter the grade point:3.2

john's average grade is $32.0

7 0
19 days ago
Which kind of file would be hurt most by lossy compression algorithm
oksian1 [804]

Response: a file containing audio

Clarification:

8 0
10 days ago
Read 2 more answers
Other questions:
  • Your computer science teacher asks you to sample a black and white image that is 4" x 6". How would you sample the image to prov
    8·1 answer
  • In the middle of the iteration, how should a team handle requirement changes from the customer? (1 correct answer)
    7·2 answers
  • Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints using ' and " shorthand. End wit
    6·2 answers
  • Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least
    10·1 answer
  • A developer writes a trigger on the Account object on the before update event that increments a count field. A workflow rule als
    12·1 answer
  • Which of the following is opened when the Find command is clicked?
    12·1 answer
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter th
    8·1 answer
  • Define a new object in variable sculptor that has properties "name" storing "Michelangelo"; "artworks" storing "David", "Moses"
    12·1 answer
  • Allison wants to use equations to simplify the process of explaining something to the Sales team, but the default eq
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!