When I run this C++ program that asks the user to enter the population of 4 cities and produce the bar graph
- it runs but ends with a Debug Error - run time check failure 2 stack around variable population was corrupted - any help would be appreciated
#include <iostream>
using namespace std;
int main()
{
int population[4],k;
int i=1,n=5;
do
{
cout<<"Enter the population of city "<<i<<":"<<endl;
cin>>population[i];
if(population[i]<0)
cout<<"population cannot be negative,Reenter\n";
else
i++;
} while (i<n);
cout<<"\n\n\t\tPOPULATION\n\t (each * = 1000 people)\n";
for(int i=1;i<n;i++)
{
cout<<"\nCity "<<i<<":";
k=population[i]/1000;
for(int j=0;j<k;j++)
cout<<"*";
}
return 0;
}
In: Computer Science
At least three paragraphs, please.
- How is the trend toward open systems and interoperability related to business use of web based systems including Cloud Computing and Software As A Service (SAAS)? Give examples of how different system platforms can use a common standard to communicate with each other. This is very important in the realm of business where not every company is using the same operating system version, file format, telecommunication standard or whatever difference that must be overcome in order to work together.
In: Computer Science
Needs to be coded in Python.
Hello i am working on a project for my computer programming course and i am having trouble with one part.
The code needs to be able to produce two versions of an output given inputs by the user. for instance.
Here is the code i have to produce the following output. The input from the user are num1 num2 and asc which is just asking if they want the output to be ascending or descending.
Code with inputs (3, 9, True)
def build_percent_pattern(num1, num2, asc):
s = ''
l = (num2 - num1) + 1
if asc == 'true':
n = 0
s += '\n'
for i in range(l):
for i in range(num1, num2 + 1):
s += '\n' + ' ' * n
n += 1
fact = 0.1 * num1
for i in range(num1, num2 + 1):
s += '{:>.2f} '.format(fact * i)
num1 += 1
return s
else:
This code produces an output such as this.
0.90 1.20 1.50 1.80 2.10 2.40 2.70
1.60 2.00 2.40 2.80 3.20 3.60
2.50 3.00 3.50 4.00 4.50
3.60 4.20 4.80 5.40
4.90 5.60 6.30
6.40 7.20
8.10
I need to somehow manipulate this code to produce an output such as this.
8.10
6.40 7.20
4.90 5.60 6.30
3.60 4.20 4.80 5.40
2.50 3.00 3.50 4.00 4.50
1.60 2.00 2.40 2.80 3.20 3.60
0.90 1.20 1.50 1.80 2.10 2.40 2.70
The function build_percent_pattern(): needs to be able to produce both of these outputs based on whether the user chooses true or false.
If someone could just modify my code for the original output to just invert it like the second output that is all i really need. Thank you again!
In: Computer Science
What is the python code to solve this type of nonlinear equation in jupyter notebook
16cos2x+16sin2x-40.1cosx+2.3sinx+16.223=0
Please show the code clearly.
In: Computer Science
Complete answer will be given an immediate upvote :)
1. Explain the rationale for returning a Boolean value from the add bag operation.
2. Explain why writing a test program before implementing a class is a good idea.
3. Why is it a safer practive for the toArray method to return a copy of the array instead of a reference to the array?
In: Computer Science
please use linux or unix to complete
Diff command
The diff command displays differences between two files on a line-by-line basis. It displays the differences as instructions that you can use to edit one of the files ( using the vi editor) to make it the same as the other. When you use diff, it produces a series of lines containing Append (a), Delete (d), and Change (c) instructions. Each of these lines is followed by the lines from the file that you need to append, delete, or change. A less than symbol (<) precedes lines from file1. A greater than symbol (>) precedes lines from file2.
You will now need four files. These are telnos, telnos2, telnos3, telnos4. These files are all short files that contain names, departments, and telephone numbers. This is what they look like.
telnos |
telnos2 |
Hale Elizabeth Bot 744-6892 |
Hale Elizabeth Bot 744-6892 |
telnos3 |
telnos 4 |
Hale Elizabeth Bot 744-6892 |
Hale Elizabeth Bot 744-6892 |
To make it easier to copy you can use the * (wildcard) to copy these files. Type in the command:
cp /tmp/csc3321/telnos* .
Remember the . (period) means current directory and will copy all of the telnos files at one time and assign them the names that they have in the instructor's file
In order to see how diff works, type in:
diff telnos telnos2
What was the result?
________________________________________________________________________________________________________________________________________________________________________________________________________________________
The difference between these two files (telnos and telnos2) is that the 4th line in telnos is missing from telnos2. The first line that diff displays (4d3) indicates that you need to delete the 4th line from file telnos to make the two files match. The 4 is the line number and the (d) is delete. The line number to the left of each of the a,c, or d instructions always pertains to file1. Numbers to the right of the instructions apply to file2. The diff command assumes that you are going to change file1 to file2. The next line that diff displays starts with a less than (<) symbol indicating that this line of text is from file1. Next type in:
diff telnos telnos3
What was the result?__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
In this case, the second line has the (>) greater than sign which means that the extra line is in file2. The a means you must append a line to the file telnos after line 2 to make it match telnos3. Append means to add on to the end. Next is an example of the change feature. Type in the following command:
diff telnos telnos4
What was the result? __________________________________________________________
What lines do you need to change in order to make the two files alike? ________________________________________________________________________________________________________________________________________________
Notice that the three hyphens indicate the end of the text in the first file that needs to be changed and the start of the second file that needs to be changed. Next, copy telnos to telnos5. What command did you use to do this? ________________________________________________________________________
Next, type in:
diff telnos5 telnos2
What was the answer that you received? _________________________________________________________________________________________________________________________________________________________________________________________________________________
Use the vi editor to change telnos5 to match the file telnos2. Then check to see if they are now alike.
What command did you use? _________________________________________________________
What was the result? __________________________________________________
What is the output of the diff command when the files
match?
_______________________________________________________________________________
When the two files are alike, there is no response. Unfortunately, Unix is not always user-friendly.
Uniq Command
The uniq command displays a file, removing all but one copy of successive repeated lines. If the file has been sorted, uniq ensures that no two lines that it displays are the same. Sort telnos and telnos3 and then send them to a new file called tel2. Type in the following:
sort telnos telnos3 > tel2
Next look at the file, tel2. What does it contain?___________________________________________________________________________________________________________________________________________________________________________________________________
Next issue the command:
uniq tel2
What was the result?__________________________________________________________________________________________________________________________________________________________________________________________________________________
The uniq command has three options. These are:
-c Causes uniq to precede each line with the number of occurrences of the line in the input file
-d Displays only lines that are repeated
-u Displays only lines that are not repeated
Issue the command:
uniq -u tel2
What was the result?__________________________________________________________________________________________________________________________________________________________________________________________________________________
Next, issue the command:
uniq -d tel2
What was the result?__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Grep Command
The grep command searches one or more files for a specified pattern. Normally each matching line is copied to the standard output. Two options that can be used with grep are:
-i
ignore
case of alphabetic characters
-n
precede each line printed by its relative line number in the input
file
Use the line numbers in the output of grep to
answer the questions in the following sections. Issue the
command:
grep -n H telnos
What was printed? ________________________________________________________________________________________________________________________________________________________________________________________________________________________
Issue the command:
grep -ni m telnos
What was printed this time?___________________________________________________________________________________________________________________________________________________________________________________________________________________
In: Computer Science
Write a function called integerPower(base, exponent) that returns the value of baseexponent
For example,
integerPower(3,4) = 3*3*3*3
An example of input/output dialog is shown below:
Enter Integer Base: 5 Enter Integer Exponent: 3 5 raised to the power of 3 = 125 Enter 0 if you'd like to end this program. Enter 1 if you'd like to run this program again: 1 Enter Integer Base: 2 Enter Integer Exponent: 4 2 raised to the power of 4 = 16 Enter 0 if you'd like to end this program. Enter 1 if you'd like to run this program again: 0 Have a nice day!
In: Computer Science
C++ Please
For this assignment, you will write a program that lets the user play against the computer in a variation of the popular blackjack car game. In this variation of the game, two-six sided dice are used instead of cards. The dice are rolled, and the player tries to beat the computer's hidden total without going over 21.
Here are some suggestions for the game's design:
You will need to create 2 class files for this assignment.
In: Computer Science
So far in this course, all of your programs have been written to be fully contained inside a single method named main. The main method is where Java begins execution of your program. In this assignment, you will coding other methods in addition to the main method. These additional methods will perform specific functions and, in most cases, return results. Write all your methods in a class named Homework6Methods.java
In: Computer Science
design a program that solves matrices by the method of gauss-seidel use the object-oriented language c ++
In: Computer Science
In linux , Using a simple text editor, create a text file with the following name "Test" and content:
GNU GENERAL PUBLIC LICENSE
The GNU General Public License is a free, copy left
license for the GNU General
Public License is intended to guarantee your freedom to GNU General
Public License
for most of our software; it applies …
2-Write the command to create the text file.
3-Print the file permissions.
4-Create a directory named "361"
5-Copy file "Test" to the directory "361"
6-Rename the file to "GNU"
7-Print the last 5 lines.
8-Change the file owner to "Reem"
9-Add Sticky bit.
10-Make a search of "General" word
Display the total number of characters in the file.
In: Computer Science
c++ Please explain why its wrong.
The findDisorder function is supposed to find the first item in
an array that
is less than the element preceding it, and set the p parameter to
point to
that item, so the caller can know the location of that item.
Explain why this
function won't do that, and show how to fix it. Your fix must be to
the
function only; you must not change the the main routine below in
any way,
yet as a result of your fixing the function, the main routine below
must
work correctly.
void findDisorder(int arr[], int n, int* p)
{
for (int k = 1; k < n; k++)
{
if (arr[k] < arr[k-1])
{
p = arr + k;
return;
}
}
p = nullptr;
}
int main()
{
int nums[6] = { 10, 20, 20, 40, 30, 50 };
int* ptr;
findDisorder(nums, 6, ptr);
if (ptr == nullptr)
cout << "The array is ordered" << endl;
else {
cout << "The disorder is at address " << ptr
<< endl;
cout << "It's at index " << ptr - nums <<
endl;
cout << "The item's value is " << *ptr <<
endl;
}
return 0;
}
In: Computer Science
Translate following function from C into RISC-V: Display Prime Numbers Between Two Intervals
#include<stdio.h>
int main(){
int low, high, i, flag;
printf("Entertwonumbers(intervals):");
scanf("%d%d",&low,&high);
printf("Primenumbersbetween%dand%dare:",low,high);
//iteration until low is not equal to high
while(low<high)
{
flag=0;
//ignore numbers less than 2
if(low<=1)
{
++low;
continue;
}
//if low is a non-prime number, flag will be 1
for(i=2;i<=low/2;++i)
{
if(low%i==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("%d",low);
//to check prime for the next number
//increase low by 1
++low;
}
return0;
}
In: Computer Science
17. Write a program that generates a random number and asks the user to guess what the
number is. If the user’s guess is higher than the random number, the program should display
“Too high, try again.” If the user’s guess is lower than the random number, the program
should display “Too low, try again.” The program should use a loop that repeats until the
user correctly guesses the random number.
18. Enhance the program that you wrote for Programming Challenge 17 so it keeps a count
of the number of guesses that the user makes. When the user correctly guesses the random
number, the program should display the number of guesses.
In Java Programming Please..
Can you please give me unique answer free from plagiarism?
I want varied opinions...
In: Computer Science
Write a complete Java Program to solve the following problem.
February 18 is a special date as this is the date that can be divisible by both 9 and 18
Write a program that asks the user for a numerical month and numerical day of the month and then determines whether that date occurs before, after, or on February 18.
If the date occurs before February 18, output the word Before. If the date occurs after February 18, output the word After. If the date is February 18, output the word Special.
Note: Passing the sample test cases are not enough to earn the full marks. You need to test your program for different months and dates to see whether your program will work in all the cases.
Input
The input consists of two integers each on a separate line.
These integers represent a date in 2015.
The first line will contain the month, which will be an integer in
the range from 1 (indicating January) to 12 (indicating
December).
The second line will contain the day of the month, which will be an
integer in the range from 1 to 31. You can assume that the day of
the month will be valid for the given month.
Output
Exactly one of Before, After or Special will be printed on one line.
Sample Input 1
1 7
Sample Output 1
Before
Sample Input 2
8 31
Sample Output 2
After
Sample Input 3
2 18
Sample Output 3
Special
Must be coded in java. Easy code for grade 11 class
In: Computer Science