Hello master programmer Can you help me solve problem 4 plea

Hello master programmer
Can you help me solve problem 4 please
Thank you sir for helping me
I will learn from you
So I can better myself and be greatest master program of them all
Question 4 Write a program that calculates triangle numbers by using a recursive function. A triangle number is the sum of all whole numbers from 1 to N, in which N is the number specified. For example, triangle(5) 5+4+ 3 2 1. (Lecture 20) Instructions for submission: 1. Each group uploads one set of files, including a word document and a .zip file including the codes. 2. Please write the group member names at the first line of the word document. 3. The zip file is the compressed file of four separate folders including the codes. 4. The word file includes the screen captures of the four programs CMUsersahangtinDesktopprogram for lecture iTConsoleApplicationivDebugiConsoleApplicatie. 1 means super EUIL and weans super NICE hink twice, why not cheese to be hink twice, why not choose to be hink twice, why not choose to be nice? hink twice, why not cheose to be ood Job Thank you. Press any key to continue of 1.1G in the vector ie 2 he larges he smallest value in the vector is 1.1 any key to cont inue AUserstrhangtinWDesktopWProge arms for Leetute he nax of 3.3 and 4.5 is 4.S he max of apple and orange is orange Press any key to continue CWUsersVrhangtinWDesktopl Programs for Lecture 19CorseleA will display ts triangle he triangle of 1 is 500S01 ress any key to continue

Solution

Im writing this in Java since no programming language was mentioned.

PROGRAM CODE:

package sample;

import java.util.Scanner;

public class TriangleNumbers {

   public static void main(String[] args) {

       //variable that will hold the N value

       int N, triangleNumber = 0;

       //scanner is used for reading the input from console

       Scanner scanner = new Scanner(System.in);

       System.out.print(\"Enter an integer value and I will display its triangle: \");

       //using nextInt() to read an integer value

       N = scanner.nextInt();

       scanner.close();

       //using for loop to add the number with itself after decrementing it each time

       for(int i=N; i>0; i--)

       {

           triangleNumber += i;

       }

       System.out.println(\"The triangle of \" + N + \" is \" + triangleNumber);

       System.out.println(\"Press any key to continue . . .\");

   }

}

OUTPUT:

Enter an integer value and I will display its triangle: 5

The triangle of 5 is 15

Press any key to continue . . .

Hello master programmer Can you help me solve problem 4 please Thank you sir for helping me I will learn from you So I can better myself and be greatest master
Hello master programmer Can you help me solve problem 4 please Thank you sir for helping me I will learn from you So I can better myself and be greatest master

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site