Lab 2
.pdf
keyboard_arrow_up
School
Austin Community College District *
*We aren’t endorsed by this school
Course
1336-018
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
8
Uploaded by SuperHumanCrocodile1969
Starting Out with Programming Logic and Design 1 Lab 2: Input, Processing, and Output This lab accompanies Chapter 2 of
Starting Out with Programming Logic & Design
. Name: ___________________________ Lab 2.1 –
Algorithms This lab requires you to think about the steps that take place in a program by writing algorithms. Read the following program prior to completing the lab. Write a program that will take in basic information from a student, including student name, degree name, number of credits taken so far, and the total number of credits required in the degree program. The program will then calculate how many credits are needed to graduate. Display should include the student name, the degree name, and credits left to graduate. Step 1:
Examine the following algorithm. (Reference: Designing a Program, page 31). 1.
Get the student name. 2.
Get the degree program name. 3.
Subtract the number of credits taken so far from the required credits for the degree. 4.
Get the number of credits required for the degree program. 5.
Get the number of credits the student has taken so far. 6.
Display the input information in Step 1 and 2. 7.
Display the calculated information. Step 2:
What logic error do you spot and how would you fix it? Critical Review An algorithm is a set of well-designed logical steps that must take place in order to solve a problem. The flow the algorithm takes is sequential. For example, before you process calculations, all data needed should be retrieved. Help Video: Double click the file to view video
Starting Out with Programming Logic and Design 2 Step 3: What steps require user interaction (Ex: user must type in some input)? Lab 2.2 –
Pseudocode Critical Review Pseudocode is an informal language that has no syntax rules and is not meant to be compiled or executed. The flow the program takes is sequential. For example, before you ask for input, you should display what information you want from the user. //Comments are done by putting two forward slashes before the lines you want to //document. Comments are used to explain code. Variables are named storage locations. "Declare" is the keyword used before naming a variable. Data types are: Real for decimal numbers, Integer for whole numbers, and String for a series of characters. Follow the rules for naming variables: (1) must be one word, no spaces, (2) usually no punctuation characters, only letters and numbers, and (3) name cannot start with a number. "Display" is the keyword used to print something to the screen. Any information needed to be displayed to the user should be put inside quotation marks such as Display “This is how you print something to the screen”
. When using display to print both a string and the value of a variable, a comma is used, such as Display “Here is the average”, average
. "Input" is the keyword used to get the user to enter data. The data value entered by the user will be placed in the variable that follows the keyword input such as Input variableName
. "Set" is the keyword used before a calculation. Standard math operators are used, such as + - * / MOD ^. Operators can be combined in one calculation, but it is wise to group expressions together using parentheses. Remember the order of operations. Some examples are Set sale = price –
discount and Set average = (test1 + test2 + test3) / 3
. Help Video: Double click the file to view video
Starting Out with Programming Logic and Design 3 This lab requires you to think about the steps that take place in a program by writing pseudocode. Read the following program prior to completing the lab. Write a program that will take in basic information from a student, including student name, degree name, number of credits taken so far, and the total number of credits required in the degree program. The program will then calculate how many credits are needed to graduate. Display should include the student name, the degree name, and credits left to graduate. Step 1
: This program is most easily solved using just five variables. Identify potential problems with the following variables declared in the pseudocode. Assume that the college has the ability to offer half credits. (Reference: Variable Names, page 39-40). Variable Name Problem (Yes or No) If Yes, what’s wrong?
Declare Real creditsTaken Declare Real credits Degree Declare Int creditsLeft Declare Real studentName Declare String degreeName Step 2:
Complete the pseudocode by writing the two missing lines. (Reference: Prompting the User, page 42). Display “Enter student name.”
Display “Enter degree program.”
Input degreeName Input creditsDegree Display “Enter the number of credits taken so far.”
Step 3
: What two things are wrong with the following calculation? (Reference: Variable Assignment and Calculations, page 43). creditsLeft = creditsTaken –
creditsDegree Step 4: Write the exact output you would expect from the following line of code if the user of the program enters “Bill Jones”.
(Reference: Displaying Items, page 40 –
41). Display “The student’s name is “, studentName
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Quizzes
Grades
2. Area of a Circle
Computer programs are great at computing mathematical formulas. Once the formula is properly encoded you can use the code as much as you want without reprogramming it and you
can share it with non-programmers without any trouble. This lab is an example of such a formula. Once you program it you won't have to worry about the area of a circle again.
Syllabus
Zoom
• Write and test a program that computes the area ofa circle. This program should request a number representing a radius as input from the user.
• Use the formula 3.14 x radius to compute the area.
• Tip: There are a couple of ways to code an exponent. Look in the Operators unit for help (and you can't use an x for multiplication).
• Tip: You will need to use the float data type to compute the remainder.
- The output should explain the results. Don't just print a number.
• Tip: For your print statement you will need to use the comma, or plus, +symbols to stitch your output together.
- (The area…
arrow_forward
Virus DNA files
As a future doctor, Jojo works in a laboratory that analyzes viral DNA. Due to the pandemic During the virus outbreak, Jojo received many requests to analyze whether there was any viral DNA in the patient. This number of requests made Jojo's job even more difficult. Therefore, Jojo ask Lili who is a programmer for help to make a program that can read the file containing the patient's DNA data and viral DNA and then match them. If on the patient's DNA found the exact same string pattern, then write to the index screen the found DNA. Data contained in the file testdata.in
Input Format
The first line of input is the number of test cases TThe second row and so on as many as T rows are the S1 string of patient DNA and the S2 string of viral DNA separated by spaces
Output Format
The array index found the same string pattern.
Constraints
1 ≤ T ≤ 1003 ≤ |S2| ≤ |S1| ≤ 100|S| is the length of the string.S will only consist of lowercase letters [a-z]
Sample Input (testdata.in)…
arrow_forward
JAVA
Project 2-3 Rectangle Calculator
Create an application that calculates the area and perimeter of a rectangle. Then using a loop, ask the user if they want to continue. If yes then repeat the input, processing, and output. If no then end the program.
Console
Welcome to the Area and Perimeter Calculator
Enter length: 100
Enter width: 200
Area: 20000.0
Perimeter: 600.0
Continue? (y/n): y
Specifications
The formulas for calculating area and perimeter are:
area = width * lengthperimeter = 2 * width + 2 * length
The application should accept decimal entries like 10.5 and 20.65.
Assume that the user will enter valid numeric data for the length and width.
The application should continue only if the user enters “y” or “Y” to continue.
Input:
Print the header "Welcome to the Area and Perimeter Calculator"
Ask the user to enter a length
Ask the user to enter a width
Processing:
Save the length and width in variables
Calculate the area and save the results in a variable…
arrow_forward
Looping is an essential component of any script or application written in Python. Looping allows you to run repeated operations without copying code. This Discussion Board is designed to help illustrate each loop type and when to use a particular loop type. Select either the For or While loop and provide the following in your Discussion Board post: A description of what the loop does An example of why you would use the loop you selected over the other Remember to use a reference to your learning materials or an outside source in at least one post each week.
arrow_forward
Basic output with variables
This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.
A variable like user_num can store a value like an integer. Extend the given program as indicated.
Output the user's input.
Output the input squared and cubed. Hint: Compute squared as user_num * user_num.
Get a second user input into user_num2, and output the sum and product.
Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.
Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20
arrow_forward
Steppermotor project:
Look at the code below and explain the code by writing an algorithm. Write an algorithm explaining the code or the project.
arrow_forward
00000000000000000
finalexamtakehome7.java
This program reads test grades from the keyboard
When -1 is entered, stop reading
Compute and display the average
00000000000
Finalexamtakehome8.java
This program reads items from the keyboard
if a letter or number is entered it displays true; otherwise
It displays false
arrow_forward
Java Code
1. FizzBuzz
by CodeChum Admin
Let’s play a game of FizzBuzz! It’s quite the same with your childhood "PopCorn" game, but with a little bit of twist to align it with programming.
Are you ready?
Instructions:
Input a positive integer in one line. This will serve as the ending point of your loop.
Loop from 1 to the ending point (inclusive) and perform the following statements:
If the number is only divisible by 3, print "Fizz"
If the number is only divisible by 5, print "Buzz"
If the number is divisible by both 3 and 5, print "FizzBuzz"
If nothing is true in the previous conditions, skip the number
Instructions
Scan a positive integer n and store it in a variable.
Create a counter variable with a value of 1 and create a loop from counter to n.
Print "Fizz" if the counter in the loop is divisible by 3, "Buzz" if the counter is divisible by 5, "FizzBuzz" if it is both divisible by 3 and 5.
Skip the iteration if it is not divisible by 3 or by 5.
Input
A line containing…
arrow_forward
Strings
For this homework, we will be creating a simple program that will take in your basic
information and then you will output the specifics outlines below. To get FULL credit, you
MUST submit the code and the output.
INPUT
a) Enter your name (first and last):
b) Enter your phone number:
c) Enter a letter that is in your name:
d) Enter a digit that is in your phone number:
OUTPUT
NAME
•
•
•
The length of your name is:
The index for the letter 'e' is:
The index for the letter 'a' is:
• The index for the letter 'q' is:
•
From c) above, replace that letter with a '2'
PHONE NUMBER
•
The length of your phone number is:
• From d) above, replace that digit with a 'X'
arrow_forward
OHM's LAW: The program can compute the current, voltage, or
resistance.
Instruction: Analyze the image given and generate the appropriate code
and computation. Write your code on any sheet of paper and submit it on
time.
O OHM's LAW
Select what you need to solve
C I- Current
O V. Voltage
CR- Resistance
45
Current
Voltage
2025
45
Resistance
COMPUTE
arrow_forward
Plz slob quickly
arrow_forward
Java Question
arrow_forward
Active buzzer project.
Write a code in C language to make an active buzzer make a sound. After writing the code , write an algorithm for the code you wrote.
arrow_forward
C# Language
should accept inputs that has decimal points
arrow_forward
mming Exercise 2.5
Instructions
momentum.py
1 # Put your code here
2 mass=int(int("Enter in kilograms:"))
3 velocity=int(int("Enter in meters per second:"))
4 print("the object's momentum is", "mass","velocity",result)
An object's momentum is its mass
multiplied by its velocity.
Write a program that accepts an object's
mass (in kilograms) and velocity (in
meters per second) as inputs, and then
outputs its momentum.
Below is an example of the progam input
and output:
Mass: 5
Velocity: 2.5
The object's momentum is 12.5
Grading
When you have completed your program.
click the Submit button to record your
Score.
arrow_forward
fast please
arrow_forward
Basic Computer Programming ActivityLanguage: CShow the code and how it works thanks
arrow_forward
CENGAGE MINDTAP
ramming Exercise 2.10
Instructions
employeepay.py
1 # Get the hourly rate
An employee's total weekly pay equals
2 hour rate= float(input( "hourly wage:"))
the hourly wage multiplied by the total
4 # Get number of hours you work regular
number of regular hours, plus any
5 regular rate= float(input("total regular hours:"))
overtime pay.
7 # Get the number of hours you work overtime
8 overtime rate= float(input("total overtime hours:"))
Overtime pay equals the total overtime
hours multiplied by 1.5 times the hourly
10 # compute total weekly pay
wage.
11 totalWeekly_pay= (regular_Hours*hour_rate)+ (overtime_Hours*1.5*
12
13 #print total weekly pay
14 print("The total weekly pay is $ ", totalWeekly Pay)
15
Write a program that takes as inputs the
hourly wage, total regular hours, and total
overtime hours and displays an
employee's total weekly pay.
Below is an example of the program
inputs and output:
Enter the wage: $15.50
Enter the regular hours: 40
Enter the overtime…
arrow_forward
python
arrow_forward
Overview
In this assignment, you will gain more practice with designing a program. Specifically, you will create pseudocode for a higher/lower game. This will give you practice designing a more complex program and allow you to see more of the benefits that designing before coding can offer. The higher/lower game will combine different programming constructs that you have been learning about, such as input and output, decision branching, and a loop.
Higher/Lower Game DescriptionYour friend Maria has come to you and said that she has been playing the higher/lower game with her three-year-old daughter Bella. Maria tells Bella that she is thinking of a number between 1 and 10, and then Bella tries to guess the number. When Bella guesses a number, Maria tells her whether the number she is thinking of is higher or lower or if Bella guessed it. The game continues until Bella guesses the right number. As much as Maria likes playing the game with Bella, Bella is very excited to play the game…
arrow_forward
Java - Painting a Wall
arrow_forward
USE C# LANGUAGE
arrow_forward
write code python language palese
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Related Questions
- Quizzes Grades 2. Area of a Circle Computer programs are great at computing mathematical formulas. Once the formula is properly encoded you can use the code as much as you want without reprogramming it and you can share it with non-programmers without any trouble. This lab is an example of such a formula. Once you program it you won't have to worry about the area of a circle again. Syllabus Zoom • Write and test a program that computes the area ofa circle. This program should request a number representing a radius as input from the user. • Use the formula 3.14 x radius to compute the area. • Tip: There are a couple of ways to code an exponent. Look in the Operators unit for help (and you can't use an x for multiplication). • Tip: You will need to use the float data type to compute the remainder. - The output should explain the results. Don't just print a number. • Tip: For your print statement you will need to use the comma, or plus, +symbols to stitch your output together. - (The area…arrow_forwardVirus DNA files As a future doctor, Jojo works in a laboratory that analyzes viral DNA. Due to the pandemic During the virus outbreak, Jojo received many requests to analyze whether there was any viral DNA in the patient. This number of requests made Jojo's job even more difficult. Therefore, Jojo ask Lili who is a programmer for help to make a program that can read the file containing the patient's DNA data and viral DNA and then match them. If on the patient's DNA found the exact same string pattern, then write to the index screen the found DNA. Data contained in the file testdata.in Input Format The first line of input is the number of test cases TThe second row and so on as many as T rows are the S1 string of patient DNA and the S2 string of viral DNA separated by spaces Output Format The array index found the same string pattern. Constraints 1 ≤ T ≤ 1003 ≤ |S2| ≤ |S1| ≤ 100|S| is the length of the string.S will only consist of lowercase letters [a-z] Sample Input (testdata.in)…arrow_forwardJAVA Project 2-3 Rectangle Calculator Create an application that calculates the area and perimeter of a rectangle. Then using a loop, ask the user if they want to continue. If yes then repeat the input, processing, and output. If no then end the program. Console Welcome to the Area and Perimeter Calculator Enter length: 100 Enter width: 200 Area: 20000.0 Perimeter: 600.0 Continue? (y/n): y Specifications The formulas for calculating area and perimeter are: area = width * lengthperimeter = 2 * width + 2 * length The application should accept decimal entries like 10.5 and 20.65. Assume that the user will enter valid numeric data for the length and width. The application should continue only if the user enters “y” or “Y” to continue. Input: Print the header "Welcome to the Area and Perimeter Calculator" Ask the user to enter a length Ask the user to enter a width Processing: Save the length and width in variables Calculate the area and save the results in a variable…arrow_forward
- Looping is an essential component of any script or application written in Python. Looping allows you to run repeated operations without copying code. This Discussion Board is designed to help illustrate each loop type and when to use a particular loop type. Select either the For or While loop and provide the following in your Discussion Board post: A description of what the loop does An example of why you would use the loop you selected over the other Remember to use a reference to your learning materials or an outside source in at least one post each week.arrow_forwardBasic output with variables This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice. A variable like user_num can store a value like an integer. Extend the given program as indicated. Output the user's input. Output the input squared and cubed. Hint: Compute squared as user_num * user_num. Get a second user input into user_num2, and output the sum and product. Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20arrow_forwardSteppermotor project: Look at the code below and explain the code by writing an algorithm. Write an algorithm explaining the code or the project.arrow_forward
- 00000000000000000 finalexamtakehome7.java This program reads test grades from the keyboard When -1 is entered, stop reading Compute and display the average 00000000000 Finalexamtakehome8.java This program reads items from the keyboard if a letter or number is entered it displays true; otherwise It displays falsearrow_forwardJava Code 1. FizzBuzz by CodeChum Admin Let’s play a game of FizzBuzz! It’s quite the same with your childhood "PopCorn" game, but with a little bit of twist to align it with programming. Are you ready? Instructions: Input a positive integer in one line. This will serve as the ending point of your loop. Loop from 1 to the ending point (inclusive) and perform the following statements: If the number is only divisible by 3, print "Fizz" If the number is only divisible by 5, print "Buzz" If the number is divisible by both 3 and 5, print "FizzBuzz" If nothing is true in the previous conditions, skip the number Instructions Scan a positive integer n and store it in a variable. Create a counter variable with a value of 1 and create a loop from counter to n. Print "Fizz" if the counter in the loop is divisible by 3, "Buzz" if the counter is divisible by 5, "FizzBuzz" if it is both divisible by 3 and 5. Skip the iteration if it is not divisible by 3 or by 5. Input A line containing…arrow_forwardStrings For this homework, we will be creating a simple program that will take in your basic information and then you will output the specifics outlines below. To get FULL credit, you MUST submit the code and the output. INPUT a) Enter your name (first and last): b) Enter your phone number: c) Enter a letter that is in your name: d) Enter a digit that is in your phone number: OUTPUT NAME • • • The length of your name is: The index for the letter 'e' is: The index for the letter 'a' is: • The index for the letter 'q' is: • From c) above, replace that letter with a '2' PHONE NUMBER • The length of your phone number is: • From d) above, replace that digit with a 'X'arrow_forward
- OHM's LAW: The program can compute the current, voltage, or resistance. Instruction: Analyze the image given and generate the appropriate code and computation. Write your code on any sheet of paper and submit it on time. O OHM's LAW Select what you need to solve C I- Current O V. Voltage CR- Resistance 45 Current Voltage 2025 45 Resistance COMPUTEarrow_forwardPlz slob quicklyarrow_forwardJava Questionarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,