I need help with this problem for computer science, have had difficulties figuring out for loops, please help, sorry the pyramid is kinda messed up but it's supposed to be a pyramid
Prog3d: Use for loops to construct a program that displays a pyramid of $ on the screen. The pyramid should look like this: [4] $ $$$ $$$$$ $$$$$$$ $$$$$$$$$ Note: There is no space in front of the first $ of last row. The above example shows only 5 lines however your program should take any integer input from the user corresponding to the number of rows to be shown. You must use the following methods: •
int main()
•int getNumberOfRowsFromUser()
• void drawPyramid(int)
#include <iostream>
using namespace std;
int main() \\main function
{
int row; \\ variable declaration
int getNumberOfRowsFromUser(); \\function declaration
void drawPyramid(int);
row=getNumberOfRowsFromUser(); \\ input function call
drawPyramid(row); \\ output function call
return(0);
}
int getNumberOfRowsFromUser() \\ input function definition
{
int=row;
cout<<"enter an integer";
cin>>row;
return(row); \\ returning row value
}
void drawPyramid(int a); \\ pyramid function definition
{
int space;
for(int i = 1, k = 0; i <= a; ++i, k = 0) \\ hear k=o means in every iteration k reset to 0
{
for(space = 1; space <= a-i; ++space) \\ space equal to row-i and when row=i,space=0
{
cout <<" "; \\ print space
}
while(k != (2*i)-1) \\ pyramid need (2*i)-1 $ in each row and when k couter meet this value,loop will terminate.
{
cout << "$";
++k;
}
cout << endl; \\ not need to print space after $,so it will terminate the row.
}
}
I need help with this problem for computer science, have had difficulties figuring out for loops,...
I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...
Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...
Need help with implementing a While, Do-while and for loops in a program. UML: - scnr : Scanner - rows : int - MAX_ASCII : int ------------------------------------------------------------------------------- + CharacterTables() : + CharacterTables(rows : int) : - getStartingValue() : int -displayTable(startValue : int) : void - userContinue() : boolean + main(args : String[]) : void In Section 5.10 we saw that there is a close relationship between char and int. Variables of type char store numbers. (Actually, variables of all types...
I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...
So I am having probelms with figuring out how to do this program the part in bold is the part I dont know how to do. This is in JAVA. What I have so far is shown below the question, this is right upto what I have to do next. Choose Your Operation Write a program that uses a WidgetViewer object to do the following: Generate two random integers between 1 and 9 (inclusive). Name one of them x, the...
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...
I've created a functioning program but I can't figure out how to implement class structure into it. I'm currently studying classes and I'm wondering if you could help me recreate my program with classes so I can have a better understanding of how classes work. Thank you. #pragma once #include <iostream> using namespace std; bool DeclareResults(char ch, char gameboard[][3]); bool FilledBoard(char gameboard[][3]); void printGameBoard(char gameboard[][3]); #include "fnt.h"; #include <iostream> using namespace std; int main() { //declare...
//please help
I can’t figure out how to print and can’t get the random numbers to
print. Please help, I have the prompt attached. Thanks
import java.util.*;
public
class
Test
{
/**
Main method */
public
static
void main(String[]
args)
{
double[][]
matrix
=
getMatrix();
//
Display the sum of each column
for
(int
col
= 0;
col
<
matrix[0].length;
col++)
{
System.out.println(
"Sum
" + col
+
" is
" +
sumColumn(matrix,
col));
}
}
/**
getMatrix initializes an...
For this assignment, you will apply what you learned in analyzing for, while, and do-while loops by writing these statements yourself. The Java™ program you write should do the following: Display a pyramid of asterisks onscreen (i.e., a nested for loop) Display the integers 10 to 1 in decreasing order, one number per line (i.e., a while/do-whlie loop) Add 7 until the sum becomes greater than 157, at which point the program should display both the sum and the number...
Plz use nested loops , read the question carefully, i need
help step by step solution using ( spyder)..
Exercise 2 Write a Python program (Lab7-ex2.py) that reads from the user an integer n, displays the triangular number sequence up to the n term (ie. 1,3, 6, 10,. n"term). The triangular of a number n is calculated as "n(n+1)/2" where n is a nonzero positive number. Note that your program should display a suitable error message if n is entered...