Question

Java Programming: A Comprehensive Introductia See this solution in the app :3 Chapter 3, Problem 17E Bookmark Show all steps:Programming in Java. Please attached the screenshot of source code and the output Thanks.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

using java programming language printed 100 alternative 1's and -1's being one as start

Raw code:

public class Alternate_1 { //creating a public class
   public static void main(String[] args) { //main method
       for (int i=0;i<101;i++) { //for loop for 100 iterations
           if(i%2==0) { //if i is even print one (1) because one should be first number
               System.out.println(1);//pinting 1
           }
           else { //if i is not an even number print -1
               System.out.println(-1);//printing -1
           }
       }
   }
}
Code in Edior:

2 ILUMNde_1.java NOVOWN 1 public class Alternate 1 (T/creating a public class public static void main(String args) 7/main met

Output:

<terminated Alternate_1 [Java Application] /Library/Java/JavaVirtual Machines/jdk1.8.0_23 2 Console X $-7-7 -7- 7-7-7-7 -7-7-

B & x T <terminated> Alternate_1 [Java Application) /Library/Java/JavaVirtual Machi - Console X 7-7 -7- 7-7-7-7- 7-7-7 -7-7-7

phpyD0BHc.png

Please feel free to comment in the comment sectiion if you have any doubts or queries

Thank you! do upvote :)

Add a comment
Know the answer?
Add Answer to:
Programming in Java. Please attached the screenshot of source code and the output Thanks. Java Programming:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming. Write your own source code with comments. (Print distinct numbers) Write a program that...

    Java Programming. Write your own source code with comments. (Print distinct numbers) Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct...

  • JAVA only Please do and post Code with Screenshot. Write a program that reads a paragraph...

    JAVA only Please do and post Code with Screenshot. Write a program that reads a paragraph from user and extract and print out any telephone number in the text. The telephone numbers can have the following formats. For this assignment you need to create objects from class Pattern and Matcher. (xxx) xxx-xxxx xxx-xxx-xxxx

  • Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you......

    Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you... PROGRAM 1 –Linear Data Structure Implementation (Due date: March 5th, 2019, 5% Grade Points) Given the starting point in a maze, you are to find and mark a path out of the maze which is represented by a 30x30 array of 1s (representing hedges) and 0s (representing the foot-paths). There is only one exit from the maze (represented by E). You may move vertically...

  • please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes...

    please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes perfect numbers according the following algorithm: for each prime, p: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 if 2P 1 s prime (2P (2 is perfect: print both p and (2P 1)(2) Note: You will need to use the Biglnteger clas for thist

  • Java Programming. Please make sure program compiles, the code is copyable, and screenshots of the output...

    Java Programming. Please make sure program compiles, the code is copyable, and screenshots of the output are provided for 5 stars :-) Calculation for speed is just supposed to be google searched 1) 18 points] You've been hired by Pedal Punchers to write a Java console application that estimates bicycle speed in miles per hour. Use a validation loop to prompt for and get from the user the wheel diameter of a bicycle in inches in the range 10-50. Then...

  • C Programming only. (NO C++) Copy & paste all source code with your answer. Also take...

    C Programming only. (NO C++) Copy & paste all source code with your answer. Also take screenshot of it compiled. 11. Write a program with the following software architecture int main) void ReadX/ OuT */ Ant *x) void IncrementX4Times(/t IO */ int *x) void Printx(/*IN */ int x) such that (1) the function ReadX) is called by the function main0 to input the value for main0 variable x from the program user as shown in the screenshot below; (2) IncrementX4Times0...

  • I need help with this problem please, This code needs to be in Ruby, Java, or...

    I need help with this problem please, This code needs to be in Ruby, Java, or Python. See problem below. -5 - Functional Programming (due Mon] Assignment Content Your software company was invited to provide a proposal for a company in Australia. You currently have the cost in US dollars and need to convert the prices to the Australian dollar. Write a 2-part program using Ruby, Java, or Python. Part 1: Write a function to gather the following costs from...

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

  • Using python, write code for problem. Please also put screenshot of your code. The following program...

    Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...

  • Please use C++ and include source code and a picture of program output. You are required...

    Please use C++ and include source code and a picture of program output. You are required to write a C++ program that interactively reads three integers, adds the numbers, and prints the result. 1- The program should use a class and an object. 2- The program can use a public function such as int FindSum (int , int y, int z) to calculate the sum of the numbers. 3- The main function should read the numbers and passes them to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT