cosc1315_l5_lab_8_1
.rtf
keyboard_arrow_up
School
Central Texas College *
*We aren’t endorsed by this school
Course
1315
Subject
Computer Science
Date
May 12, 2024
Type
rtf
Pages
1
Uploaded by MinisterFalconPerson641
Lesson 5 Lab 8.1 – Input Validation
Critical Review
If a computer reads bad data as input, it will produce bad data as output. Programs should be designed to reject bad data that is given as input. Garbage in, garbage out (GIGO), refers to the fact that computers cannot tell the difference between good data and bad date. Both numbers and strings can be validated.
The goal of this lab is to identify potential errors with algorithms and programs.
Step 1: Imagine a program that calls for the user to enter a password of at least 8 alphanumeric characters. Identify at least two potential input errors.
Password conatins symbol
password has less than 8
Step 2: Imagine a program that calls for the user to enter patients’ blood pressure. Blood pressure ranges are between 50 and 230. Identify at least two potential input errors.
BP isnt a number
BP isnt below 50 or over 230
Step 3: Open your Lab 5-3.rap flowchart. This program allowed the user to enter in 7 days’ worth of bottle returns and then calculated the average. Examine the program and identify at least two potential input errors.
input not a number
input is negative
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
uity.com/player/
ester A
1 2
3
traveling salesperson problem
O heuristic
Mark this and return
O
M
0
Save and Exit
G
A program uses artificial intelligence to simulate a human player in a virtual chess game. The program cannot compute every possible combination of
moves and outcomes for the game in a reasonable amount of time. Instead, the program uses an algorithm that sacrifices exactness and approximates
the move with the best chance of success. This algorithm is an example of which of the following?
O superpolynomial time
Obrute force
Next
English
V
O Sign out
V
19
D
Kinley Ha
TIME REMAINING
52:47
Submit
Mar 27
10:31
arrow_forward
UML Design for Turing Machine
Description:
An electro-mechanical device used by the British cryptologists to help
decipher German Enigma-machine-encrypted secret messages during World War II.
A Turing Machine is a very simple abstract model of computation. The machine has an
infinite tape that is divided into cells (or squares). Each cell contains a symbol (or character)
chosen from some small set of possible symbols. Most of the cells are blank, that is, they
contain the blank symbol. The number of non-blank cells is finite. The machine is located on
one of the cells, and it can only "see" the symbol in the cell where it is located. It can write a
new value to that cell. It can move left or right on the tape, one cell at a time. The machine is in
one of a fixed, finite number of possible states. One of the states is the halt state.
A Turing Machine has a table of rules. The table of rules is the program for the machine. A rule
tells the machine what action to take when it is in a…
arrow_forward
Question 4 - Algorithm Design
Imagine you are a treasure hunter standing at one side of the river. There are n (a positive
integer) stones on the river. They are aligned on a straight line and at the nth stone, there is
treasure waiting for you. Your target is to reach the nth stone. For each move, you have the
choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you
are not allowed to travel backwards. Design an algorithm that calculates the number of ways
(sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the
algorithm and demonstrate the correctness of the algorithm with a complete proof.
Here is an example. For n =
1
5, there are 8 ways:
Method 1: walk → walk → walk → walk → walk
Method 2: walk → walk → walk → leap
Method 3: walk → walk → leap → walk
Method 4: walk → leap → walk →
walk
walk
Method 5: leap → walk → walk →
Method 6: leap → leap walk
Method 7: leap → walk → leap
Method 8: walk → leap leap
arrow_forward
1. Broken Record
by CodeChum Admin
Looping strings works like playing a broken record – it repeats something over and over again. But what's great about loops is that we can define as to how many times it will repeat something with proper code, and that's what we're about to do now using while() loops.
arrow_forward
Moon effect. Some people believe that the Moon controls their activities. If the Moon moves from being directly on the opposite side of
Earth from you to being directly overhead, by what percentage does (a) the Moon's gravitational pull on you increase and (b) your
weight (as measured on a scale) decrease? Assume that the Earth-Moon (center-to-center) distance is 3.82 x 10° m, Earth's radius is
6.37 x 106 m, Moon's mass is 7.36 x 1022 kg, and Earth's mass is 5.98 x 1024 kg.
(a) Number
6.89
Units
percent
(b) Number
i
6.8713e-4
Units
percent
arrow_forward
Algorithm writing
Instructions:
Algorithms are a generic way of describing a
solution to a computational problem without
use of any specific programming language
syntax. It cannot be executed on a real
computer, but it can model and resemble real
programming code. Natural language is used
whenever details are unimportant or
distracting.
Your algorithm:
Must be unambiguous (exact)..are the steps
numbered? .do we always know where to go next
or are we left hanging?
Must be correct (solves the problem)...are the
'requirements' being met?
Must come to an end (terminate)...how do we
know when to end this?
Must be general (for all cases).. .can we input
any data & still solve the problem?
Must be at the right level of detail... . will a
computer (in general) understand what we are
asking it to do?
Requirements --> You have a store that sells
lemons and oranges. Oranges are $.30 each and
lemons are $.15 each. Your solution to this
problem should get from the user the numbers
of oranges and…
arrow_forward
Canvas Login - Santa Monica College
E Quiz: Module 3: Assignment - Loops
G The lecture demonstrated how to read a line wit
Problem Statement
Output Numbers from 1 to N: Write a program that prints out every other number between 1 and N where N is entered by the user. The numbers must be separated by a comma and a space. The last number must not have a comma
following it. The program is repeated until a number smaller than 1 is entered at which point the program outputs "Goodbye!"
Example:
Enter N: 7
1, 3, 5, 7
Enter N: 10
1, 3, 5, 7,9
Enter N: -1
Goodbye!
Partial Solution
Please try to implement the full source code in your IDE first. The solution is partially provided below. Fill in the blanks to complete the missing parts and make sure to not add an empty space before and after the answer.
using namespace std;
int
Int n- 0;
/get a user input for n
cout>
lprintout every other number
(int i- 1;1 <- n; i +- 2){
cout <<
Nprintout a comma after a number but not the last one.
Iffl < n-1){…
arrow_forward
Direction Fields
Plotting Direction fields can be done using the function quiver:
quiver Quiver plot.
quiver (X,Y.U.V) plots velocity vectors as arrows with components (u.v) at the points (x,y). The matrices X,Y,U,V must all be the same size
and contain corresponding position and velocity components (X and Y can also be vectors to specify a uniform grid). quiver automatically
scales the arrows to fit within the grid.
Example:
xrange = -5:0.5:5; %the domain of x is from -5 up to 5 with 0.5 interval.
yrange= -10:1:10; %the values of y is from -10 up to 10 with 1 interval.
[x,y] meshgrid(xrange,yrange);
Xplot the DE
y = x^2+y^2;
S = x.^2+y^2;
quiver (x,y,ones (size(s)),s)
Exercises:
Sketch the direction fields of the following differential equations
1. y = 0.25xy²
2. y = sin(x-y)
Notes:
For the ranges:
For Item No.1
Use xr1 = (-5,5) with 0.5 interval yr1 = (-10,10) with 0.5 interval
Use s1 for the f(x,y). x1 and y1 as the points in the rectangular coordinate system,
For Item No.2
Use xr2…
arrow_forward
CodeWorkout
Gym
Course
Search exercises...
Q Search
kola shreya@columbus
X275: Recursion Programming Exercise: Check Palindrome
X275: Recursion Programming Exercise: Check
Palindrome
Write a recursive function named checkPalindrome that takes a string as input, and returns true if the string is a
palindrome and false if it is not a palindrome. A string is a palindrome if it reads the same forwards or backwards.
Recall that str.charAt(a) will return the character at position a in str. str.substring(a) will return the substring of
str from position a to the end of str,while str.substring(a, b) will return the substring of str starting at position
a and continuing to (but not including) the character at position b.
Examples:
checkPalindrome ("madam") -> true
Your Answer:
1 public boolean checkPalindrome (String s) {
4
CodeWorkout © Virginia Tech
About
License
Privacy
Contact
arrow_forward
Vocabulary
Task (C language)
Solution given below. How to fix the error in the picture attached. txt file is not being created from this code
please also include how to create a txt file and where will it be saved in the computer
Natural language processing (NLP) is a field of artificial intelligence that seeks to develop the ability of a computer program to understand human language. Usually, the first step of an NLP system is to convert words into numeric codes. Thus, the system converts an input text into a sequence of numeric codes before any high-level analysis. This process is known as text preprocessing.
We can only perform text preprocessing if we have a vocabulary of words and their associated numeric codes. Your task is to create a vocabulary of unique words for a given text file and assign a different number from 1 to N to each unique word, with N being the total number of unique words. You must perform this assignment so that the first word in alphabetical order gets the…
arrow_forward
The Philosophers' Dinner Problem
Five philosophers sit around a table and spend their lives dining and thinking. Each philosopher has a bowl of noodles and a fork to the left of your plate. To eat the noodles you need two forks and each philosopher you can only take the ones to your left and right. If any philosopher takes a fork and the other is busy, he will wait, fork in hand, until pick up the other fork, so you can start eating later. If two adjacent philosophers try to pick up the same fork at the same time, a race condition: they both compete to take the same fork, and one of them left without eating. If all the philosophers take the fork to their right at the same time, then everyone will be waiting forever, because someone must release the fork that is lack. No one will because everyone is in the same situation (hoping that someone put down their forks). Then the philosophers will starve. This lock mutual is called deadlock or deadlock. The problem is to find an algorithm that…
arrow_forward
Exercise 2 - Learning to Trace (to Fix Semantic Errors)
This exercise should be done in the "Exercise2" file providea to you. A major part of being able to
trace your program to find out what's wrong is first figuring out what the program should be doing,
and then looking at the output that the program currently produces to see what it is actually doing.
In this way, you can identify what's not right, or, specifically, which part of the code is not doing
the right thing and make the necessary adjustments.
We want a program which, when run, should be providing the following output:
Required Output:
Welcome user. This program demonstrates the importance of fixing semantic errors.
In addition, it helps you calculate your final mark and the test mark needed to pass with a certain
final mark.
The prac mark is 75% which is weighted at 0.4
The tut mark is 67% which is weighted at 0.35
The test mark is 68% which is weighted at 0.25
The target final mark is 75%
With the current marks, you're…
arrow_forward
1. Number Sorter in Matlab
Requirements:
● Must be a console program
● Reads integers from standard input (i.e from the user via the keyboard) until a number less than or equal to zero is input. This indicates the end of input.
● Once end of input is detected, the program sorts all of the numbers in ascending order and displays them
● You can choose any sort algorithms. For instance:
○ choose a random input, n, not yet sorted in the list of input values
○ go through the list of input values and place all values less than n to the left of n and all other values to the right of n
○ Once this is done then n is sorted, so go back and repeat the first step
○ Once all values n are sorted the entire list is sorted
● You are not allowed the built-in function sort in Matlab to solve this problem
2) In 200 explain how the program function.
Note : manually solve the vector using any algorithm but don't use the built-in function "sort " in matlab…
arrow_forward
3. Number Sorter in Matlab
Requirements:
● Must be a console program
● Reads integers from standard input (i.e from the user via the keyboard) until a number less than or equal to zero is input. This indicates the end of input.
● Once end of input is detected, the program sorts all of the numbers in ascending order and displays them
● You can choose any sort algorithms. For instance:
○ choose a random input, n, not yet sorted in the list of input values
○ go through the list of input values and place all values less than n to the left of n and all other values to the right of n
○ Once this is done then n is sorted, so go back and repeat the first step
○ Once all values n are sorted the entire list is sorted
● You are not allowed the built-in function sort in Matlab to solve this problem.
* use octave to do this question
* write 150 words to explain the program and how it works .
.
arrow_forward
Python question
Application: Python Fragment Formulation (Q1 – Q4)
In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task.
Question 1 (Reduce parentheses)
Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying.
(x**(2**y))+(y*((z+x)**3))
Question 2 (Translate arithmetic concept into Python)
You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers.
Note: the product of two numbers, x and y is x*y.
Question 3 (List/table access)
You are given a table,…
arrow_forward
Problem Description:
In the Whimsical Library, each book is enchanted with a magical code to ensure the
protection of knowledge. The validation process for these magical codes involves a
combination of mathematical spells.
The validation process is described as follows:
Take the sum of the digits at odd positions from left to right.
Take the sum of the squared digits at even positions from left to right.
If the absolute difference between the results from step 1 and step 2 is a prime
number, the book code is considered valid; otherwise, it is invalid.
Example 1:
Consider the magical book code 86420137.
Step 1. Take the sum of the digits at odd positions from left to right.
8+4+0+3=15
Step 2. Take the sum of the squared digits at even positions from left to right.
6^2+2^2+1^2+7^2=36+4+1+49 = 90
Step 3. If the absolute difference between the results from step 1 and step 2 is a prime
number.
115-901 75 (not a prime number)
Book code 86420137 is invalid.
Example 2:
Now, let's examine the…
arrow_forward
Decrease-by-Constant-Factor Fake-Coin puzzle method in Java or C++ to find the fake coin out of n coins. Assume the false coin is lighter. Randomly place the false coin among the n coins. Submit results images and code files.
arrow_forward
Problem Description
The hailstone sequence is defined as the integer sequence that results from manipulating a positive
integer value n as follows:
If n is even, divide it by 2 (using floor division)
• If n is odd, multiply it by 3 and then add 1
Repeat this process until you reach 1.
For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1.
If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1.
If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1.
If n is 8, we get the sequence 8, 4, 2, 1.
As far as anyone can tell, this process will eventually reach 1 for any starting value, although
mathematicians have been unable to formally prove this property as of yet.
a. Write a Python function named hail () that takes a single integer argument. hail() should
print out the sequence of numbers generated by applying the process above to the function
parameter. This function does not return any value.
arrow_forward
Direction: Read each sentence/ situation carefully and select the BEST answer among the choices.
1. It is a Boolean expression that tells when the loop will exit.
2. The sequence that makes up the loop body may either be a block of Turbo C statements or a single Turbo C statement.
3. In Turbo C it is a reserved word.
4. Its values determine the number of times the loop iterates.
5. It is the second type of open-ended loop.
Condition
For Loop
Statement
For
Do while Loop
arrow_forward
Celebrity problem A celebrity among a group of n people is a person who knows nobody but is known by everybody else. The task is to identify a celebrity by only asking questions to people of the form: ”Do you know him/her?” Solution Select two people from the group given, say, A and B, and ask A whether A knows B. If A knows B, remove A from the remaining people who can be a celebrity; if A doesn’t know B, remove B from this group. Solve the problem recursively for the remaining group of people who can be a celebrity
Which design strategy does the following solution use?
A-)Decrease-by-a-constant factor algorithm
B-)Variable-size-decrease algorithm
C-)Decrease-by-a-constant algorithm
D-)Divide-and-Conquer
arrow_forward
CODING LANGUAGE: R (similar to python)
R is a programming language for statistical computing and graphics supported by the R Core Team and the R Foundation for Statistical Computing.
The Behdel TestThe Bechdel test asks whether a work of fiction features at least two women who talk to each otherabout something other than a man, and there must be two women named characters.In this mini analysis we work with the data used in the FiveThirtyEight story titled:"The Dollar-And-Cents Case Against Hollywood's Exclusion of Women"https://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women/Start with loading the packages: fivethirtyeight, tidyverse1. What information does this dataset contain? What commands did you use to see this?For our purposes of analysis we will focus our analysis on movies released between 1990 and 2013.bechdel90_13 <- bechdel %>%filter(between(year, 1990, 2013))2. How many movies are in our filtered data set?The…
arrow_forward
Force Completion This test can be saved and resumed at any point until time has expired. The timer will continue to run if you leave the te
Your answers are saved automatically.
>Show Timer
* Question Completion Status:
QUESTION 1
Experience has shown that the best way to construct a program is from small pieces. This is called
O bottom up
O the whole is greater than the sum of the parts
O divide and conquer
O recursion
approach.
Click Save and Submit to save and submit. Click Save All Answers to save all answers.
25
arrow_forward
Complete the following sentences.
MATLAB includes a special debugging tool called a
debugger, which is embedded into the Edit/Debug Window. This tool allows you to walk through the execution of your program one statement
at a time, and to examine the values of any variables at each step along the way.
arrow_forward
Output for Sample Input 1
3+
Copy
arrow_forward
Recursive Multiplication
Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows:
7×4=4+4+4+4+4+4+4(To keep the function simple, assume that x and y will always hold positive nonzero integers.)
arrow_forward
JAVA LANGUAGE
Body Mass Index Version 2.0
by CodeChum Admin
Recall that according to the National Heart, Lung, and Blood Institute of the National Institutes of Health, body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to monitor one's health by determining whether one is underweight, overweight, has normal weight or is obese. It is computed based as follows (when using standard weight in pounds and height in inches):
BMI = 703 x (weight/(height2))
Furthermore, people with BMI scores that are less than 18.5 are said to be underweight. Those with scores between 18.5–24.9 (inclusive) are of normal weight. Those with scores between 25–29.9 (inclusive) are said to be overweight. And those with scores 30 or higher are obese.
Input
The input is composed of two positive integers representing the weight in pounds and the height in inches.
140·65
Output
A single line containing two values: the computed…
arrow_forward
* Question Completion Status:
A Moving to another question will save this response.
Question 9
Given the function F(X,Y,Z) =XZ + Z(X'+ XY), the equivalent, most simplified Boolean representation for F is
O a. Z+XYZ
O b.XZ
O c. Z
O d.Z+YZ
A Moving to another question will save this response.
مشمس 36°C
arrow_forward
REPETITION CONTROL STRUCTURE (FOR)
Instruction:
Write a Java program that reads a positive, non-zero integer as input and checks if the
integer is deficient, perfect, or abundant.
A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors
(i.e., the positive integers, other than N itself, that divide N exactly) is equal to the number
itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than
N, the number is said to be abundant.
The first few perfect numbers are 6, 28, 496, and 8128.
Illustrations:
Number
Factors of the number less than itself Sum of Factors
3, 2, 1
14, 7, 4, 2, 1
6
6
28
28
For example, the number 6 is perfect, since 6 = 1 + 2 + 3, the number 8 is deficient, since
8 >1 + 2 + 4, while the number 12 is abundant, since 12<1 + 2 + 3 + 4 + 6.
Sample Input/Output:
Depicted below are sample outputs when the program is executed (the items in bold
characters are input from the user, while the items…
arrow_forward
4) Roll the dice 2
Make a program that tests the probability of a certain score when rolling x dice. The user should be
able to choose to roll eg 4 dice and test the probability of a selected score eg 11. The program should
then do a number of simulations and answer how big the probability is for the selected score with as
many dice selected. There must be error checks so that you cannot enter incorrect sums, for
example, it is not possible to get the sum 3 if you roll 4 dice.
TarningsKast2
How many dices do you want to throw?
11
Which number do you want the probability for?
The probability the get the number 11 with 4 dices is 7.19%
Calculate
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
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
Related Questions
- uity.com/player/ ester A 1 2 3 traveling salesperson problem O heuristic Mark this and return O M 0 Save and Exit G A program uses artificial intelligence to simulate a human player in a virtual chess game. The program cannot compute every possible combination of moves and outcomes for the game in a reasonable amount of time. Instead, the program uses an algorithm that sacrifices exactness and approximates the move with the best chance of success. This algorithm is an example of which of the following? O superpolynomial time Obrute force Next English V O Sign out V 19 D Kinley Ha TIME REMAINING 52:47 Submit Mar 27 10:31arrow_forwardUML Design for Turing Machine Description: An electro-mechanical device used by the British cryptologists to help decipher German Enigma-machine-encrypted secret messages during World War II. A Turing Machine is a very simple abstract model of computation. The machine has an infinite tape that is divided into cells (or squares). Each cell contains a symbol (or character) chosen from some small set of possible symbols. Most of the cells are blank, that is, they contain the blank symbol. The number of non-blank cells is finite. The machine is located on one of the cells, and it can only "see" the symbol in the cell where it is located. It can write a new value to that cell. It can move left or right on the tape, one cell at a time. The machine is in one of a fixed, finite number of possible states. One of the states is the halt state. A Turing Machine has a table of rules. The table of rules is the program for the machine. A rule tells the machine what action to take when it is in a…arrow_forwardQuestion 4 - Algorithm Design Imagine you are a treasure hunter standing at one side of the river. There are n (a positive integer) stones on the river. They are aligned on a straight line and at the nth stone, there is treasure waiting for you. Your target is to reach the nth stone. For each move, you have the choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you are not allowed to travel backwards. Design an algorithm that calculates the number of ways (sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the algorithm and demonstrate the correctness of the algorithm with a complete proof. Here is an example. For n = 1 5, there are 8 ways: Method 1: walk → walk → walk → walk → walk Method 2: walk → walk → walk → leap Method 3: walk → walk → leap → walk Method 4: walk → leap → walk → walk walk Method 5: leap → walk → walk → Method 6: leap → leap walk Method 7: leap → walk → leap Method 8: walk → leap leaparrow_forward
- 1. Broken Record by CodeChum Admin Looping strings works like playing a broken record – it repeats something over and over again. But what's great about loops is that we can define as to how many times it will repeat something with proper code, and that's what we're about to do now using while() loops.arrow_forwardMoon effect. Some people believe that the Moon controls their activities. If the Moon moves from being directly on the opposite side of Earth from you to being directly overhead, by what percentage does (a) the Moon's gravitational pull on you increase and (b) your weight (as measured on a scale) decrease? Assume that the Earth-Moon (center-to-center) distance is 3.82 x 10° m, Earth's radius is 6.37 x 106 m, Moon's mass is 7.36 x 1022 kg, and Earth's mass is 5.98 x 1024 kg. (a) Number 6.89 Units percent (b) Number i 6.8713e-4 Units percentarrow_forwardAlgorithm writing Instructions: Algorithms are a generic way of describing a solution to a computational problem without use of any specific programming language syntax. It cannot be executed on a real computer, but it can model and resemble real programming code. Natural language is used whenever details are unimportant or distracting. Your algorithm: Must be unambiguous (exact)..are the steps numbered? .do we always know where to go next or are we left hanging? Must be correct (solves the problem)...are the 'requirements' being met? Must come to an end (terminate)...how do we know when to end this? Must be general (for all cases).. .can we input any data & still solve the problem? Must be at the right level of detail... . will a computer (in general) understand what we are asking it to do? Requirements --> You have a store that sells lemons and oranges. Oranges are $.30 each and lemons are $.15 each. Your solution to this problem should get from the user the numbers of oranges and…arrow_forward
- Canvas Login - Santa Monica College E Quiz: Module 3: Assignment - Loops G The lecture demonstrated how to read a line wit Problem Statement Output Numbers from 1 to N: Write a program that prints out every other number between 1 and N where N is entered by the user. The numbers must be separated by a comma and a space. The last number must not have a comma following it. The program is repeated until a number smaller than 1 is entered at which point the program outputs "Goodbye!" Example: Enter N: 7 1, 3, 5, 7 Enter N: 10 1, 3, 5, 7,9 Enter N: -1 Goodbye! Partial Solution Please try to implement the full source code in your IDE first. The solution is partially provided below. Fill in the blanks to complete the missing parts and make sure to not add an empty space before and after the answer. using namespace std; int Int n- 0; /get a user input for n cout> lprintout every other number (int i- 1;1 <- n; i +- 2){ cout << Nprintout a comma after a number but not the last one. Iffl < n-1){…arrow_forwardDirection Fields Plotting Direction fields can be done using the function quiver: quiver Quiver plot. quiver (X,Y.U.V) plots velocity vectors as arrows with components (u.v) at the points (x,y). The matrices X,Y,U,V must all be the same size and contain corresponding position and velocity components (X and Y can also be vectors to specify a uniform grid). quiver automatically scales the arrows to fit within the grid. Example: xrange = -5:0.5:5; %the domain of x is from -5 up to 5 with 0.5 interval. yrange= -10:1:10; %the values of y is from -10 up to 10 with 1 interval. [x,y] meshgrid(xrange,yrange); Xplot the DE y = x^2+y^2; S = x.^2+y^2; quiver (x,y,ones (size(s)),s) Exercises: Sketch the direction fields of the following differential equations 1. y = 0.25xy² 2. y = sin(x-y) Notes: For the ranges: For Item No.1 Use xr1 = (-5,5) with 0.5 interval yr1 = (-10,10) with 0.5 interval Use s1 for the f(x,y). x1 and y1 as the points in the rectangular coordinate system, For Item No.2 Use xr2…arrow_forwardCodeWorkout Gym Course Search exercises... Q Search kola shreya@columbus X275: Recursion Programming Exercise: Check Palindrome X275: Recursion Programming Exercise: Check Palindrome Write a recursive function named checkPalindrome that takes a string as input, and returns true if the string is a palindrome and false if it is not a palindrome. A string is a palindrome if it reads the same forwards or backwards. Recall that str.charAt(a) will return the character at position a in str. str.substring(a) will return the substring of str from position a to the end of str,while str.substring(a, b) will return the substring of str starting at position a and continuing to (but not including) the character at position b. Examples: checkPalindrome ("madam") -> true Your Answer: 1 public boolean checkPalindrome (String s) { 4 CodeWorkout © Virginia Tech About License Privacy Contactarrow_forward
- Vocabulary Task (C language) Solution given below. How to fix the error in the picture attached. txt file is not being created from this code please also include how to create a txt file and where will it be saved in the computer Natural language processing (NLP) is a field of artificial intelligence that seeks to develop the ability of a computer program to understand human language. Usually, the first step of an NLP system is to convert words into numeric codes. Thus, the system converts an input text into a sequence of numeric codes before any high-level analysis. This process is known as text preprocessing. We can only perform text preprocessing if we have a vocabulary of words and their associated numeric codes. Your task is to create a vocabulary of unique words for a given text file and assign a different number from 1 to N to each unique word, with N being the total number of unique words. You must perform this assignment so that the first word in alphabetical order gets the…arrow_forwardThe Philosophers' Dinner Problem Five philosophers sit around a table and spend their lives dining and thinking. Each philosopher has a bowl of noodles and a fork to the left of your plate. To eat the noodles you need two forks and each philosopher you can only take the ones to your left and right. If any philosopher takes a fork and the other is busy, he will wait, fork in hand, until pick up the other fork, so you can start eating later. If two adjacent philosophers try to pick up the same fork at the same time, a race condition: they both compete to take the same fork, and one of them left without eating. If all the philosophers take the fork to their right at the same time, then everyone will be waiting forever, because someone must release the fork that is lack. No one will because everyone is in the same situation (hoping that someone put down their forks). Then the philosophers will starve. This lock mutual is called deadlock or deadlock. The problem is to find an algorithm that…arrow_forwardExercise 2 - Learning to Trace (to Fix Semantic Errors) This exercise should be done in the "Exercise2" file providea to you. A major part of being able to trace your program to find out what's wrong is first figuring out what the program should be doing, and then looking at the output that the program currently produces to see what it is actually doing. In this way, you can identify what's not right, or, specifically, which part of the code is not doing the right thing and make the necessary adjustments. We want a program which, when run, should be providing the following output: Required Output: Welcome user. This program demonstrates the importance of fixing semantic errors. In addition, it helps you calculate your final mark and the test mark needed to pass with a certain final mark. The prac mark is 75% which is weighted at 0.4 The tut mark is 67% which is weighted at 0.35 The test mark is 68% which is weighted at 0.25 The target final mark is 75% With the current marks, you're…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
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