Publicidad

Write a function that uses a for loop to print five consecutive number (1).docx

5 de Feb de 2023
Write a function that uses a for loop to print five consecutive number (1).docx
Write a function that uses a for loop to print five consecutive number (1).docx
Próximo SlideShare
Cuilumber Candle Supply makes candles- The sales mix (as a percmtage o.docxCuilumber Candle Supply makes candles- The sales mix (as a percmtage o.docx
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Más de lez31palka(20)

Publicidad

Write a function that uses a for loop to print five consecutive number (1).docx

  1. Write a function that uses a for loop to print five consecutive numbers, and prints their sum. At the end. it would print the average. The output should have the following format: Solution ForTest.java public class ForTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub displayValues(); } public static void displayValues(){ int sum = 0; System.out.println("NumbertSum"); for(int i=4; i<=8; i++){ sum = sum + i; System.out.println(i+"t"+sum); } System.out.println("Average = "+(sum/5)); } } Output: Number  Sum 4  4 5  9 6  15 7  22
  2. 8Â Â 30 Average = 6
Publicidad