Sign In
Not register? Register Now!
Pages:
4 pages/β‰ˆ1100 words
Sources:
No Sources
Style:
APA
Subject:
IT & Computer Science
Type:
Other (Not Listed)
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 21.6
Topic:

Java Programs Understanding Pseudocode, Flowcharts, and the Test Plan

Other (Not Listed) Instructions:

“Understanding Pseudocode, create Flowcharts, and a the Test Plan,” create a Word document that contains the pseudocode, flowchart, and test plan for both projects.
here is project program 1 Count positive and negative numbers and compute the average of numbers)
Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number.
Sample Run 1
Enter an integer, the input ends if it is 0: 1 2 -1 3 0
The number of positives is 3
The number of negatives is 1
The total is 5.0
The average is 1.25
Sample Run 2
Enter an integer, the input ends if it is 0: 0
No numbers are entered except 0
Sample Run 3
Enter an integer, the input ends if it is 0: 2 3 4 5 0
The number of positives is 4
The number of negatives is 0
The total is 14
The average is 3.5
Sample Run 4
Enter an integer, the input ends if it is 0: -4 3 2 -1 0
The number of positives is 2
The number of negatives is 2
The total is 0
The average is 0.0
Class Name: Exercise05_01
this is the program:
import java.util.Scanner;
public class Exercise05_01 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int positiveCount = 0;
int negativeCount = 0;
double total = 0;
System.out.print("Enter an integer, the input ends if it is 0: ");
while (true) {
int number = input.nextInt();
if (number == 0) {
break;
} else if (number > 0) {
positiveCount++;
} else {
negativeCount++;
}
total += number;
}
input.close();
if (positiveCount + negativeCount == 0) {
System.out.println("No numbers are entered except 0");
} else {
double average = total / (positiveCount + negativeCount);
System.out.println("The number of positives is " + positiveCount);
System.out.println("The number of negatives is " + negativeCount);
System.out.println("The total is " + total);
System.out.println("The average is " + average);
}
}
}
Projet 2 program 2 (Business: check ISBN-13)
ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13. The last digit d13 is a checksum, which is calculated from the other digits using the following formula:
10 - (d1 + 3d2 + d3 + 3d4 + d5 + 3d6 + d7 + 3d8 + d9 + 3d10 + d11 + 3d12) % 10
If the checksum is 10, replace it with 0. Your program should read the input as a string.
Display “invalid input” if the input is incorrect.
Sample Run 1
Enter the first 12 digits of an ISBN-13 as a string: 978013213080
The ISBN-13 number is 9780132130806
Sample Run 2
Enter the first 12 digits of an ISBN-13 as a string: 978013213079
The ISBN-13 number is 9780132130790
Sample Run 3
Enter the first 12 digits of an ISBN-13 as a string: 97801320
97801320 is an invalid input
Class Name: Exercise05_47
program 2
import java.util.Scanner;
public class Exercise05_47 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the first 12 digits of an ISBN-13 as a string: ");
String inputString = input.nextLine();
if (inputString.length() != 12) {
System.out.println(inputString + " is an invalid input");
} else {
int checksum = calculateChecksum(inputString);
String isbn13 = inputString + checksum;
System.out.println("The ISBN-13 number is " + isbn13);
}
input.close();
}
public static int calculateChecksum(String inputString) {
int sum = 0;
for (int i = 0; i < inputString.length(); i++) {
int digit = Character.getNumericValue(inputString.charAt(i));
if (i % 2 == 0) {
sum += digit;
} else {
sum += 3 * digit;
}
}
int checksum = 10 - (sum % 10);
if (checksum == 10) {
return 0;
} else {
return checksum;
}
}
}

Other (Not Listed) Sample Content Preview:


Java Programs Understanding Pseudocode, Flowcharts, and the Test Plan
Students name
Course
University
Professor’s name
Date
PROGRAM 1
Program1-Pseudocode
Function main:
Declare and initialize positiveCount = 0
Declare and initialize negativeCount = 0
Declare and initialize total = 0
Declare and initialize Number=0
output("Enter an integer, the input ends if it is 0: ")
//start an infinite loop
while (true)
{
//enter a number
number = input.nextInt()
// Check if the entered number is 0
if (number == 0)
{
// Exit the loop if the number is 0
break
}
else if (number > 0)
{
// Increment positive count if the number is positive
positiveCount++
}
else {
// Increment negative count if the number is negative
negativeCount++
}
// Accumulate the number to the total
total += number
}
// Close the input scanner
input.close()
// Check if no numbers (except 0) are entered
if (positiveCount + negativeCount == 0)
{
output ("No numbers are entered except 0")
}
else
{
// Calculate the average
average = total / (positiveCount + negativeCount)
// Display results
output("The number of positives is " + positiveCount)
output("The number of negatives is " + negativeCount)
output("The total is " + total)
output("The average is " + average)
}
End Function Main
-371475171450YESNONOYESNUMBER>OENDaverage = total / (positiveCount + negativeCount) NUMBER==0?STARTDECLARE AND INITILIAZE VARIABLES- positiveCount, negativeCount, total and numberINCREMENT POSITIVESINCREMENT NEGATIVESADD NUMBER TO TOTALPROMPT USER TO ENTER A NUMBERoutput("The number of positives is " + positiveCount)output("The number of negatives is " + negativeCount)output("The total is " + total) output("The average is " + average)YESNONOYESNUMBER>OENDaverage = total / (positive

...
Updated on
Get the Whole Paper!
Not exactly what you need?
Do you need a custom essay? Order right now:

πŸ‘€ Other Visitors are Viewing These APA Other (Not Listed) Samples:

HIRE A WRITER FROM $11.95 / PAGE
ORDER WITH 15% DISCOUNT!