1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kompoz [17]
3 years ago
10

Write an application that inputs three numbers (integer) from a user. (10 pts) UPLOAD Numbers.java a. display user inputs b. det

ermine and display the number of negative inputs c. determine and display the number of positive inputs d. determine and display the number of zero inputs e. determine and display the number of even inputs f. determine and display the number of odd inputs
Computers and Technology
1 answer:
SCORPION-xisa [38]3 years ago
7 0

Answer:

The program to this question as follows:

Program:

import java.util.*; //import package for user input

public class Number //defining class Number

{

public static void main(String[] ak)throws Exception //defining main method

{

int a1,b1,c1; //defining integer variable

int p_Count=0,n_Count=0,n_Zero=0,even_Count=0,odd_Count=0;

Scanner obx=new Scanner(System.in); //creating Scanner class object

System.out.println("Input all three numbers: "); //print message

//input from user

a1=obx.nextInt(); //input value

b1=obx.nextInt(); //input value

c1=obx.nextInt(); //input value

//check condition for a1 variable value

if(a1>0) //positive number

p_Count++;

else if(a1==0) //value equal to 0

n_Zero++;

else //value not equal to 0

n_Count++;

if(a1%2==0)//check even number

even_Count++;

else //for odd number

odd_Count++;

//check condition for b1 variable value

if(b1>0) //positive number

p_Count++;

else if(b1==0) //value equal to 0

n_Zero++;

else //value not equal to 0

n_Count++;

if(b1%2==0) //check even number

even_Count++;

else //for odd number

odd_Count++;

//check condition for c1 variable value

if(c1>0) //positive number

p_Count++;

else if(c1==0) //value equal to 0

n_Zero++;

else //value not equal to 0

n_Count++;

if(c1%2==0) //check even number

even_Count++;

else //for odd number

odd_Count++;

//print values.

System.out.println("positive number: "+p_Count);//message

System.out.println("negative number: "+n_Count); //message

System.out.println("zero number: "+n_Zero); //message

System.out.println("even number: "+even_Count); //message

System.out.println("odd number: "+odd_Count); //message

}

}

Output:

Input all three numbers:

11

22

33

positive number: 3

negative number: 0

zero number: 0

even number: 1

odd number: 2

Explanation:

In the above java program code a class is defined in this class three integer variable "a1,b1, and c1" is defined which is used to take input value from the user end, and other integer variable "p_Count=0, n_Count=0, n_Zero=0, even_Count=0, and odd_Count=0" is defined that calculates 'positive, negative, zero, even, and odd' number.

  • In the next step, the conditional statement is used, in if block a1 variable, b1 variable, c1 variable calculates it checks value is greater then 0, it will increment the value of positive number value by 1.
  • else if it will value is equal to 0. if this condition is true it will negative number value by 1
  • else it will increment zero number values by 1.
  • In this code, another if block is used, that checks even number condition if the value matches it will increment the value of even number by 1, and at the last print, method is used that print all variable values.
You might be interested in
Identify two areas of science or technology that make your life easier, safer, or otherwise better than your grandparents lives
vladimir2022 [97]
Heres some:

Quantum computing
Machine Learning
Medicine
Aeronautical Engineering (Drones, better transportation)
8 0
3 years ago
Please use thread to complete the following program: one process opens a file data.txt, then creates a thread my_thread. The job
Firlakuza [10]

Answer:

Here is the code:-

//include the required header files

#include<stdio.h>

#include<pthread.h>

// method protocol definition

void *count_lines(void *arg);

int main()

{

    // Create a thread handler

    pthread_t my_thread;

    // Create a file handler

    FILE *fh;

    // declare the variable

    int *linecnt;

    // open the data file

    fh=fopen("data.txt","r");

// Create a thread using pthread_create; pass fh to my_thread;

    pthread_create(&my_thread, NULL, count_lines, (void*)fh);

    //Use pthread_join to terminate the thread my_thread

    pthread_join( my_thread, (void**)&linecnt );

    // print the number of lines

printf("\nNumber of lines in the given file: %d \n\n", linecnt);

    return (0);

}

// Method to count the number of lines

void *count_lines(void *arg)

{

    // variable declaration and initialization

    int linecnt=-1;

    char TTline[1600];

    //code to count the number of lines

    while(!feof(arg))

    {

         fgets(TTline,1600,arg);

         linecnt++;

    }

    pthread_exit((void *)linecnt);

    // close the file handler

    fclose(arg);

}

Explanation:

Program:-

8 0
3 years ago
1. What are copyright laws? (6 points)
Serggg [28]

Can u pls help me. srry i had to ask u on here lol

8 0
3 years ago
Write a method named rotateright that accepts an array of integers as a parameter and rotates the values in the array to the rig
trasher [3.6K]
You should really state what language you are using. I have produced your method in C#, and should be easily translatable in to any other language.

static void RotateRight<T>(T[] arr)
{          
    T temp = arr[arr.Length - 1];
   
    for (int i = arr.Length - 1; i >= 0; i--)
    {               
        if (i == 0)                   
            arr[i] = temp;               
        else                   
            arr[i] = arr[i - 1];           
    }       
}
3 0
3 years ago
15. Select the correct answer.
givi [52]

Answer:

Pixel dimensions

Explanation:

measure of height and width of a image in pixels

3 0
3 years ago
Other questions:
  • ♡ Another Dum Question But Oh Wells -.- ♡
    12·2 answers
  • Define what is meant by an entity in a data model. How should an entity be named? What information about an entity should be sto
    5·1 answer
  • _________ cards contain a chip that can store a large amount of information as well as on a magnetic stripe for backward compati
    12·1 answer
  • Alice is adding a chart in a spreadsheet. Which option will allow you her to give the chart a suitable title and subtitle?
    11·2 answers
  • On net, is technology good or bad for society? Please explain, support your argument, I’ll mark brainliest
    9·2 answers
  • What is virtual office?
    11·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    6·1 answer
  • Which of the following is a correct statement about writing down passwords on a ""cheat sheet?""
    7·1 answer
  • How computer viruses spread from one computer to another​
    10·1 answer
  • what is the greatest number of bits you could borrow from the host portion of a class b subnet mask and still have at least 130
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!