Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*i need help with 3 different java programs* 1)/* ******************************************************** The program prompts for a value which will determine the number of repetitions for the

*i need help with 3 different java programs*

1)/* ******************************************************** The program prompts for a value which will determine the number of repetitions for the loop. Within the loop the program will prompt for a number and add the value value entered to an accumulator.******************************************************** */import java.util.Scanner;public class Lab0701 { public static void main(String[] args) { int limit = 0; int counter = 0; int valu = 0; int sum = 0; float avg = 0.0F;// Prompt for a repetition limit Scanner kBd = new Scanner(System.in); System.out.print("Sum from 0 to...? "); limit = kBd.nextInt();// Develop the loop to sum the values between one (1) and the limit entered bythe user// while (conditional expression) {} System.out.println(" The sum of the numbers between 0 and " + limit + " is..." + sum); System.out.println(" **** end of Lab0701 **** ");}

2)

// The program will provide a count of// the upper case letters in the string// provided. public class Lab0703 {

public static void main(String[] args) {

char c;int count = 0;int i = 0;

String lineIn = "AranDomlINeoFiNPutToTeSt"; System.out.println("Input: " + lineIn);

/* Note:

the while loop is controlled bythe length of the string */

while(i < lineIn.length()) { c = lineIn.charAt(i); if(Character.isUpperCase(c)) count++; i++; } System.out.println("Count is: " + count); }

3)

import java.util.Scanner;public class Lab0704 {

public static void main(String[] args) {

int runTime = 0;int totalTime = 0;double avg = 0.0;int numTimes = 0;Scanner inp = new Scanner(System.in); System.out.print(" Enter running time in seconds or -1 to end: ");runTime = inp.nextInt();while(runTime != -1){

totalTime += runTime;System.out.print(" Enter running time in seconds or -1 to

end: ");

runTime = inp.nextInt();

}

// insert code to report the total time, the number of times entered and theaverage time }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions