SlideShare a Scribd company logo
1 of 4
Download to read offline
Please complete in Java.
/**
*
* Implement all the methods described below.
*
* Student name: YOUR NAME GOES HERE.
*/
public class Subroutines1 {
///////////////////////////////////////////////////////////////////////////
// The main() method tests your program's completeness.
public static void main(String[] args) {
int numCorrect = 0;
if( getMaximum(1, 2, 3) == 3 ) { numCorrect++; }
if( getMaximum(4,-5, 2) == 4 ) { numCorrect++; }
if( getMaximum(0, 7, 5) == 7 ) { numCorrect++; }
if( !isEven(3) ) { numCorrect++; }
if( isEven(-2) ) { numCorrect++; }
if( isEven(0) ) { numCorrect++; }
if( !isEven(-2*(int)(Math.random()*100)+1) ) {numCorrect++;}
if( !hasG( "man" ) ) { numCorrect++; }
if( hasG( "dog" ) ) { numCorrect++; }
if( hasG( "EGGSHELL" ) ) { numCorrect++; }
if( indexOfG( "man" ) == -1 ) { numCorrect++; }
if( indexOfG( "EGGSHELL" ) == 1 ) { numCorrect++; }
if( indexOfG( "dog" ) == 2 ) { numCorrect++; }
if( indexOfG( "xyzggGGggG" ) == 3 ) { numCorrect++; }
if( indexOfG( "xyzGGggGGg" ) == 3 ) { numCorrect++; }
System.out.println( "Your program's completeness is currently: "
+ numCorrect + "/15" );
}
///////////////////////////////////////////////////////////////////////////
/**
* Returns largest of its arguments.
* @param x First argument
* @param y Second argument
* @param z Third argument
* @return Maximum of x, y and z
*/
private static int getMaximum( int x, int y, int z) {
// REPLACE THE METHOD BODY
// This is an obviously wrong return value
// that exists only to allow the file to compile
return -1000;
}
///////////////////////////////////////////////////////////////////////////
/**
* Is the argument even?
* (Recall that even numbers are divisible by 2)
* @param x Value to check.
* @return True if x is an even number, false otherwise.
*/
private static boolean isEven( int x ) {
// REPLACE THE METHOD BODY
// Hardcoded value will be "correct" sometimes,
// but you must make it work for all input
return false;
}
///////////////////////////////////////////////////////////////////////////
/**
* Does the given string contain the letter G (either upper or
* lower case)?
* @param x String to check
* @return True if x contains G, false otherwise.
*/
private static boolean hasG( String x ) {
// REPLACE THE METHOD BODY
// Again, hardcoding a value to compile
return false;
}
///////////////////////////////////////////////////////////////////////////
/**
* Where is the location of the letter G (upper or lower case) in
* the given string?
* @param x String to check
* @return 0 based location of first occurrence of G in x,
* -1 if G is not present.
*/
private static int indexOfG( String x ) {
// REPLACE THE METHOD BODY
// This is an obviously wrong return value
// that exists only to allow the file to compile
return -1234;
}
///////////////////////////////////////////////////////////////////////////
}
1 Assignment Description I have provided you with some starter code in a file named
Subroutines1.java. Open this file in your editor and use it as a starting point. Do not modify the
main() method. Using this code, complete all the methods as written in the descriptions provided.
There are four methods that must be completed. The program will test your methods and assign a
completeness score when run out of 15 . Submitting code that compiles and produces a score of
15/15 is expected. 2 Turning in your assignment Submit your Subroutines1.java file to the Lab 5
assignment in Canvas. Do not attach .class files or any other files. 3 Grading Rubric (total of 30
points) A (5 points): Exactly one file submitted in Canvas with name Subroutines1.java B (5
points): Compiles and runs without errors C (5 points): Adheres to the coding standards D (15
points): Passes 15 tests (1 point per test) IMPORTANT: You will not receive credit for a method
if you merely hard code the test case output rather than correctly implementing the described
behavior.

More Related Content

Similar to Please complete in Java. Implement all the methods.pdf

PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docxjoyjonna282
 
golang_refcard.pdf
golang_refcard.pdfgolang_refcard.pdf
golang_refcard.pdfSpam92
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile DevelopmentJan Rybák Benetka
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageGiuseppe Arici
 
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongTechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongGrokking VN
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongVu Huy
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfarmyshoes
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfOrtus Solutions, Corp
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)aeden_brines
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentzjkdg986
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentfdjfjfy4498
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentsdfgsdg36
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresGowtham Reddy
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsRasan Samarasinghe
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
 

Similar to Please complete in Java. Implement all the methods.pdf (20)

3 j unit
3 j unit3 j unit
3 j unit
 
PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docx
 
golang_refcard.pdf
golang_refcard.pdfgolang_refcard.pdf
golang_refcard.pdf
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen LuongTechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
TechkTalk #12 Grokking: Writing code that writes code – Nguyen Luong
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen Luong
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdf
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
 
Unit testing
Unit testingUnit testing
Unit testing
 
lecture 6
 lecture 6 lecture 6
lecture 6
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 

More from amarnathmahajansport

Please ask experts to solve this in the correct way. 1. (20 point.pdf
Please ask experts to solve this in the correct way.  1. (20 point.pdfPlease ask experts to solve this in the correct way.  1. (20 point.pdf
Please ask experts to solve this in the correct way. 1. (20 point.pdfamarnathmahajansport
 
please answer this multiple choice question2.What major Department.pdf
please answer this multiple choice question2.What major Department.pdfplease answer this multiple choice question2.What major Department.pdf
please answer this multiple choice question2.What major Department.pdfamarnathmahajansport
 
please answer this multiple choice question4.This Technical Review.pdf
please answer this multiple choice question4.This Technical Review.pdfplease answer this multiple choice question4.This Technical Review.pdf
please answer this multiple choice question4.This Technical Review.pdfamarnathmahajansport
 
Please answer question in full 2.1 Security management function.pdf
Please answer question in full  2.1 Security management function.pdfPlease answer question in full  2.1 Security management function.pdf
Please answer question in full 2.1 Security management function.pdfamarnathmahajansport
 
Please answer these questions 150 words only 1) List four lines o.pdf
Please answer these questions 150 words only  1) List four lines o.pdfPlease answer these questions 150 words only  1) List four lines o.pdf
Please answer these questions 150 words only 1) List four lines o.pdfamarnathmahajansport
 
Please answer the 4 questions at the end please do all of them at th.pdf
Please answer the 4 questions at the end please do all of them at th.pdfPlease answer the 4 questions at the end please do all of them at th.pdf
Please answer the 4 questions at the end please do all of them at th.pdfamarnathmahajansport
 
Please answer the questions in orderExplain why a virus is co.pdf
Please answer the questions in orderExplain why a virus is co.pdfPlease answer the questions in orderExplain why a virus is co.pdf
Please answer the questions in orderExplain why a virus is co.pdfamarnathmahajansport
 
Please answer the questions in orderCompare and contrast Virus a.pdf
Please answer the questions in orderCompare and contrast Virus a.pdfPlease answer the questions in orderCompare and contrast Virus a.pdf
Please answer the questions in orderCompare and contrast Virus a.pdfamarnathmahajansport
 
Please answer the questions in ordarExplain the advantage for sur.pdf
Please answer the questions in ordarExplain the advantage for sur.pdfPlease answer the questions in ordarExplain the advantage for sur.pdf
Please answer the questions in ordarExplain the advantage for sur.pdfamarnathmahajansport
 
Please give a detailed summary of the article where I can write at l.pdf
Please give a detailed summary of the article where I can write at l.pdfPlease give a detailed summary of the article where I can write at l.pdf
Please give a detailed summary of the article where I can write at l.pdfamarnathmahajansport
 
Please answer the 4 questions at the end Causes and Outcomes of Co.pdf
Please answer the 4 questions at the end Causes and Outcomes of Co.pdfPlease answer the 4 questions at the end Causes and Outcomes of Co.pdf
Please answer the 4 questions at the end Causes and Outcomes of Co.pdfamarnathmahajansport
 
please help In multiple regression analysis, residuals (YY^) shou.pdf
please help  In multiple regression analysis, residuals (YY^) shou.pdfplease help  In multiple regression analysis, residuals (YY^) shou.pdf
please help In multiple regression analysis, residuals (YY^) shou.pdfamarnathmahajansport
 
please fill in the chart A company that uses job order c.pdf
please fill in the chart A company that uses job order c.pdfplease fill in the chart A company that uses job order c.pdf
please fill in the chart A company that uses job order c.pdfamarnathmahajansport
 
Please fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfPlease fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfamarnathmahajansport
 
Please explain fully each step and what inputs and the number of row.pdf
Please explain fully each step and what inputs and the number of row.pdfPlease explain fully each step and what inputs and the number of row.pdf
Please explain fully each step and what inputs and the number of row.pdfamarnathmahajansport
 
please explain how attaker crack 2DES and show your work. 3DES = Run.pdf
please explain how attaker crack 2DES and show your work. 3DES = Run.pdfplease explain how attaker crack 2DES and show your work. 3DES = Run.pdf
please explain how attaker crack 2DES and show your work. 3DES = Run.pdfamarnathmahajansport
 
Please explain answer choice 26. Small functionally disruptive hardw.pdf
Please explain answer choice 26. Small functionally disruptive hardw.pdfPlease explain answer choice 26. Small functionally disruptive hardw.pdf
Please explain answer choice 26. Small functionally disruptive hardw.pdfamarnathmahajansport
 
Please explain answer choice 15. Match each of the following counter.pdf
Please explain answer choice 15. Match each of the following counter.pdfPlease explain answer choice 15. Match each of the following counter.pdf
Please explain answer choice 15. Match each of the following counter.pdfamarnathmahajansport
 
Please draw an activity diagram using Enterprise. or draw using symb.pdf
Please draw an activity diagram using Enterprise. or draw using symb.pdfPlease draw an activity diagram using Enterprise. or draw using symb.pdf
Please draw an activity diagram using Enterprise. or draw using symb.pdfamarnathmahajansport
 

More from amarnathmahajansport (20)

Please ask experts to solve this in the correct way. 1. (20 point.pdf
Please ask experts to solve this in the correct way.  1. (20 point.pdfPlease ask experts to solve this in the correct way.  1. (20 point.pdf
Please ask experts to solve this in the correct way. 1. (20 point.pdf
 
please answer this multiple choice question2.What major Department.pdf
please answer this multiple choice question2.What major Department.pdfplease answer this multiple choice question2.What major Department.pdf
please answer this multiple choice question2.What major Department.pdf
 
please answer this multiple choice question4.This Technical Review.pdf
please answer this multiple choice question4.This Technical Review.pdfplease answer this multiple choice question4.This Technical Review.pdf
please answer this multiple choice question4.This Technical Review.pdf
 
Please answer question in full 2.1 Security management function.pdf
Please answer question in full  2.1 Security management function.pdfPlease answer question in full  2.1 Security management function.pdf
Please answer question in full 2.1 Security management function.pdf
 
Please answer these questions 150 words only 1) List four lines o.pdf
Please answer these questions 150 words only  1) List four lines o.pdfPlease answer these questions 150 words only  1) List four lines o.pdf
Please answer these questions 150 words only 1) List four lines o.pdf
 
Please answer the 4 questions at the end please do all of them at th.pdf
Please answer the 4 questions at the end please do all of them at th.pdfPlease answer the 4 questions at the end please do all of them at th.pdf
Please answer the 4 questions at the end please do all of them at th.pdf
 
Please answer the questions in orderExplain why a virus is co.pdf
Please answer the questions in orderExplain why a virus is co.pdfPlease answer the questions in orderExplain why a virus is co.pdf
Please answer the questions in orderExplain why a virus is co.pdf
 
Please answer the questions in orderCompare and contrast Virus a.pdf
Please answer the questions in orderCompare and contrast Virus a.pdfPlease answer the questions in orderCompare and contrast Virus a.pdf
Please answer the questions in orderCompare and contrast Virus a.pdf
 
Please answer the questions in ordarExplain the advantage for sur.pdf
Please answer the questions in ordarExplain the advantage for sur.pdfPlease answer the questions in ordarExplain the advantage for sur.pdf
Please answer the questions in ordarExplain the advantage for sur.pdf
 
Please give a detailed summary of the article where I can write at l.pdf
Please give a detailed summary of the article where I can write at l.pdfPlease give a detailed summary of the article where I can write at l.pdf
Please give a detailed summary of the article where I can write at l.pdf
 
Please answer the 4 questions at the end Causes and Outcomes of Co.pdf
Please answer the 4 questions at the end Causes and Outcomes of Co.pdfPlease answer the 4 questions at the end Causes and Outcomes of Co.pdf
Please answer the 4 questions at the end Causes and Outcomes of Co.pdf
 
please help In multiple regression analysis, residuals (YY^) shou.pdf
please help  In multiple regression analysis, residuals (YY^) shou.pdfplease help  In multiple regression analysis, residuals (YY^) shou.pdf
please help In multiple regression analysis, residuals (YY^) shou.pdf
 
please fill in the chart A company that uses job order c.pdf
please fill in the chart A company that uses job order c.pdfplease fill in the chart A company that uses job order c.pdf
please fill in the chart A company that uses job order c.pdf
 
Please fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfPlease fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdf
 
Please explain fully each step and what inputs and the number of row.pdf
Please explain fully each step and what inputs and the number of row.pdfPlease explain fully each step and what inputs and the number of row.pdf
Please explain fully each step and what inputs and the number of row.pdf
 
please explain how attaker crack 2DES and show your work. 3DES = Run.pdf
please explain how attaker crack 2DES and show your work. 3DES = Run.pdfplease explain how attaker crack 2DES and show your work. 3DES = Run.pdf
please explain how attaker crack 2DES and show your work. 3DES = Run.pdf
 
Please explain answer choice 26. Small functionally disruptive hardw.pdf
Please explain answer choice 26. Small functionally disruptive hardw.pdfPlease explain answer choice 26. Small functionally disruptive hardw.pdf
Please explain answer choice 26. Small functionally disruptive hardw.pdf
 
Please explain answer choice 15. Match each of the following counter.pdf
Please explain answer choice 15. Match each of the following counter.pdfPlease explain answer choice 15. Match each of the following counter.pdf
Please explain answer choice 15. Match each of the following counter.pdf
 
Please draw an activity diagram using Enterprise. or draw using symb.pdf
Please draw an activity diagram using Enterprise. or draw using symb.pdfPlease draw an activity diagram using Enterprise. or draw using symb.pdf
Please draw an activity diagram using Enterprise. or draw using symb.pdf
 
please do the extr.pdf
please do the extr.pdfplease do the extr.pdf
please do the extr.pdf
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Recently uploaded (20)

FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 

Please complete in Java. Implement all the methods.pdf

  • 1. Please complete in Java. /** * * Implement all the methods described below. * * Student name: YOUR NAME GOES HERE. */ public class Subroutines1 { /////////////////////////////////////////////////////////////////////////// // The main() method tests your program's completeness. public static void main(String[] args) { int numCorrect = 0; if( getMaximum(1, 2, 3) == 3 ) { numCorrect++; } if( getMaximum(4,-5, 2) == 4 ) { numCorrect++; } if( getMaximum(0, 7, 5) == 7 ) { numCorrect++; } if( !isEven(3) ) { numCorrect++; } if( isEven(-2) ) { numCorrect++; } if( isEven(0) ) { numCorrect++; } if( !isEven(-2*(int)(Math.random()*100)+1) ) {numCorrect++;} if( !hasG( "man" ) ) { numCorrect++; } if( hasG( "dog" ) ) { numCorrect++; } if( hasG( "EGGSHELL" ) ) { numCorrect++; } if( indexOfG( "man" ) == -1 ) { numCorrect++; } if( indexOfG( "EGGSHELL" ) == 1 ) { numCorrect++; } if( indexOfG( "dog" ) == 2 ) { numCorrect++; }
  • 2. if( indexOfG( "xyzggGGggG" ) == 3 ) { numCorrect++; } if( indexOfG( "xyzGGggGGg" ) == 3 ) { numCorrect++; } System.out.println( "Your program's completeness is currently: " + numCorrect + "/15" ); } /////////////////////////////////////////////////////////////////////////// /** * Returns largest of its arguments. * @param x First argument * @param y Second argument * @param z Third argument * @return Maximum of x, y and z */ private static int getMaximum( int x, int y, int z) { // REPLACE THE METHOD BODY // This is an obviously wrong return value // that exists only to allow the file to compile return -1000; } /////////////////////////////////////////////////////////////////////////// /** * Is the argument even? * (Recall that even numbers are divisible by 2) * @param x Value to check. * @return True if x is an even number, false otherwise. */ private static boolean isEven( int x ) {
  • 3. // REPLACE THE METHOD BODY // Hardcoded value will be "correct" sometimes, // but you must make it work for all input return false; } /////////////////////////////////////////////////////////////////////////// /** * Does the given string contain the letter G (either upper or * lower case)? * @param x String to check * @return True if x contains G, false otherwise. */ private static boolean hasG( String x ) { // REPLACE THE METHOD BODY // Again, hardcoding a value to compile return false; } /////////////////////////////////////////////////////////////////////////// /** * Where is the location of the letter G (upper or lower case) in * the given string? * @param x String to check * @return 0 based location of first occurrence of G in x, * -1 if G is not present. */ private static int indexOfG( String x ) { // REPLACE THE METHOD BODY
  • 4. // This is an obviously wrong return value // that exists only to allow the file to compile return -1234; } /////////////////////////////////////////////////////////////////////////// } 1 Assignment Description I have provided you with some starter code in a file named Subroutines1.java. Open this file in your editor and use it as a starting point. Do not modify the main() method. Using this code, complete all the methods as written in the descriptions provided. There are four methods that must be completed. The program will test your methods and assign a completeness score when run out of 15 . Submitting code that compiles and produces a score of 15/15 is expected. 2 Turning in your assignment Submit your Subroutines1.java file to the Lab 5 assignment in Canvas. Do not attach .class files or any other files. 3 Grading Rubric (total of 30 points) A (5 points): Exactly one file submitted in Canvas with name Subroutines1.java B (5 points): Compiles and runs without errors C (5 points): Adheres to the coding standards D (15 points): Passes 15 tests (1 point per test) IMPORTANT: You will not receive credit for a method if you merely hard code the test case output rather than correctly implementing the described behavior.