Question

Using C# and including comments: Name this project SquaresAndCubes Write a Console Application initializes a variable...

Using C# and including comments: Name this project SquaresAndCubes Write a Console Application initializes a variable to an integer value then prints out a table with the number, its square, and its cube. The program then adds one to the value and does the same on the next line. The program then adds one to the value again and does the same on the third line. The program then adds one to the value again and does the same on the fourth line: Example: If the value is 3 then the output should look like this: Number Square Cube 3 9 27 4 16 64 5 25 125 6 36 216

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;

class SquaresAndCubes {

  

public static void Main (string[] args) {

// Declare the required variables

int num, square, cube;

int i;

// Take radius and length input from the user

Console.WriteLine ("Enter a number : ");

// Convert the input from the user to double value

num = int.Parse(Console.ReadLine());

for (i=1;i<=4;i++){

Console.WriteLine(num+" "+num*num+" "+num*num*num);

num += 1;

}

}

}

PLEASE RATE ANSWER

Add a comment
Know the answer?
Add Answer to:
Using C# and including comments: Name this project SquaresAndCubes Write a Console Application initializes a variable...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ console application that adds the corresponding elements of two integer arrays of size...

    Write a C++ console application that adds the corresponding elements of two integer arrays of size five. Prompt the user for the ten values and store the first five in the first array and the second five in the second array. Then create and call function matrixAdd that adds the two arrays and prints the five sums. Here is the function prototype: void matrixAdd(int firstArr[], int secondArr[]); [your program code here]*

  • QUESTION 12 Write a program that would prompt the user to enter an integer. The program...

    QUESTION 12 Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube = x...

  • 1) Write a program that: program starts; declares and initializes to zero an integer variable score;...

    1) Write a program that: program starts; declares and initializes to zero an integer variable score; declares and initializes to zero a float variable total; uses a for loop statement with integer x initialized to 1 going 5 iterations hence x<5 incremented by 0; input from keyboard integer score in range of 0 to 99; print on new line input value; adds score to total; switch x equals 3 break default x++; after exiting the loop calculate the average score;...

  • Write a C# console application that has one method to perform the four basic arithmetic operations...

    Write a C# console application that has one method to perform the four basic arithmetic operations of add, subtract, multiply, and divide. In the main program, first print a line on the console showing your name. Call the method you created above with each of the four arithmetic operations. You have to pass the method two integer numbers as well as a flag for which operation you want the method to perform. The method performs the operation on the numbers...

  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

  • Write a complete Java program, including comments in both the main program and in each method,...

    Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once.      This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...

  • #include <iostream> using namespace std; int main() {    } Write a program that, given a...

    #include <iostream> using namespace std; int main() {    } Write a program that, given a user-specified integer, prints out the next 10 integers (in increasing order; each on its own line). For example, given an input of 3, the console content following a run of the completed program will look as follows: Enter a number: 3 4 5 6 7 8 9 10 11 12 13

  • Write a C++ console application that calculates and displays the charges for multiple customers using a...

    Write a C++ console application that calculates and displays the charges for multiple customers using a parking garage. The parking garage charges a minimum fee of $3.00 to park for up to three hours. The garage charges an additional $0.85 per hour or fraction of an hour for parking over three hours. The maximum charge for any given 24-hour period is $20.00. You may assume that no car parks for longer than 24 hours at a time. Your program will...

  • Write a C++ console application that uses functions to calculate an employee’s salary.

    Write a C++ console application that uses functions to calculate an employee’s salary.PART 1: Create a void function to print a menu asking the user to choose from the following options:1 - Annual salary2 - Monthly salary3 - Daily rate of pay4 – ExitThe void function only prints the menu. Format your cout statement to include the menu as displayed above.If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and...

  • Include outputs. Write a C# console application named Tape that includes fields for length and width...

    Include outputs. Write a C# console application named Tape that includes fields for length and width in inches and properties for each field. Also include a ToString() method that returns a string constructed from the return value of the object's GetType() method and the values of the length and width fields. Derive two subclasses - VideoCassetteTape and AdhesiveTape. The VideoCassetteTape class includes an integer field to hold playing time in minutes - a value from 1 to 180 - and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT