Question

5. (12 points) Consider the following code fragment (part of a program): int index 3; String dna ACTGTCA char nucleotide dna
0 0
Add a comment Improve this question Transcribed image text
Answer #1

5)

C) int, char and String : Data types

int , char and String are data types used in C for integer, character and String types of data respectively.

A) index ,nucleotide and dna : Variable names

index , nucleotide and dna are variable names of values that are used in this program for different evaluations.

B) 3 and "ACTGTCA" : Literals

3 and "ACTGTCA" are fixed integer and string values respectively in this program called literals.

F) dna : Object

dna is a String object that is created in this program which is used to call a function called charAt.

E) charAt : Method

string_name.charAt(parameter) is a method used to return the character at the given position (parameter) of the string_name . In this program character at the index 3 of the string value in dna , ie, 'G' will be returned.

D) index : Parameter

index is the parameter used for the charAt function in this program.

6)

a) STATEMENT:- (since you didn't mention which language to use, I'm using the default C language as per HomeworkLib rule)

#include <stdio.h>

#include<stdbool.h>

int main()

{

float temperature;

bool fever;

printf("Enter your temperature : ");

scanf("%f", &temperature);

if ( temperature > 98.6 )

fever = true;

else

fever = false;

printf("%d");

return 0;

}

(The bold portion is the answer to the question.. I wrote the whole program, so u can run it for testing)

b) TESTING OF THE ABOVE CODE:

if u enter any floating point number less than or equal to 98.6 , the output will be 0 (false).

If u enter any floating point number greater than 98.6 (ie, from 98.61 to etc.....) ,the output will be 1 (true).

7)METHOD isValid

#include <stdio.h» 2 #include <stdboo1.h» 3/ bool function1(int num) bool x if (numnum 1num2) x true; else x- false; return x

(line 3 to 11 is the answer to the question., I wrote the whole code so that you can test it by yourself if needed. The program above was a sample program I used to test the code so I just gave the function name as function1 . SO PLEASE CHANGE IT TO isValid WHILE YOU COPY IT.)

I HOPE THIS WILL HELP YOU. PLEASE RATE IF U LIKE IT. THANKS FOR READING

Add a comment
Know the answer?
Add Answer to:
5. (12 points) Consider the following code fragment (part of a program): int index 3; String...
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
  • Question 5 (3 points) (Bonus) Below shows a recursive method that can recognize whether a String...

    Question 5 (3 points) (Bonus) Below shows a recursive method that can recognize whether a String parameter consists of a specific pattern and returns true if the String has that pattern, false otherwise. public boolean pattern Recognizer(String 2) return true; if (2 == null) return true; else if (a.length(== 11 |(a.length() == 2&&2.charAt(0) == 2.charAt()))) else if (a.length() == 2 && 2.charAt(0) != a.charAt(1)) return false; else if (a.charAt(0) == a.charAt(a.length() - 1)) retum patterRecognizer(a substring(1, a.length() - 1)): else...

  • What is the output of this code segment? double [] a = {-1.2, 3.1, -4.7, 38.0,...

    What is the output of this code segment? double [] a = {-1.2, 3.1, -4.7, 38.0, 0.0}; double temp = a[0]; for (int i = 1; i < a.length; i++) { if (a[i] < temp) { temp = a[i]; } } System.out.println (temp); What does this method do? In one short English sentence describe the task accomplished by this method. public static int foo(int [] a) { int temp = 0; for (int i = 0; i < a.length; i++)...

  • I am unsure how to add the following methods onto this code?? please help - rowValuesIncrease(int[][]...

    I am unsure how to add the following methods onto this code?? please help - rowValuesIncrease(int[][] t) A method that returns true if from left to right in any row, the integers are increasing, otherwise false. - columnValuesIncrease(int[][] t) A method that returns true if from top to bottom in any column, the integers are increasing, otherwise false. - isSetOf1toN(int[][] t) A method that returns true if the set of integers used is {1, 2, . . . , n}...

  • Given the following code fragment public class Point { public int x; // Because these are...

    Given the following code fragment public class Point { public int x; // Because these are public, you can access them public int y; // directly without getters and setters }; public class Rectangle { private Point ll; // the lower left corner of the rectangle private Point ur; // the upper right corner of the rectangle public Point getLLPoint() {return ll;} public Point getURPoint() {return ur;} } (a) Write a method equals for the Rectangle class that takes a...

  • language is java Restrictions: You are not allowed to use anything from the String, StringBuilder, or...

    language is java Restrictions: You are not allowed to use anything from the String, StringBuilder, or Wrapper classes. In general, you may not use anything from any other Java classes, unless otherwise specified. You are not allowed to use String literals in your code ("this is a string literal"). You are not allowed to use String objects in your code. The methods must be implemented by manipulating the data field array, The CSString Class: NOTE: Pay very careful attention to...

  • Write the Java code for the class WordCruncher. Include the following members:

    **IN JAVAAssignment 10.1 [95 points]The WordCruncher classWrite the Java code for the class WordCruncher. Include the following members:A default constructor that sets the instance variable 'word' to the string "default".A parameterized constructor that accepts one String object as a parameter and stores it in the instance variable. The String must consist only of letters: no whitespace, digits, or punctuation. If the String parameter does not consist only of letters, set the instance variable to "default" instead. (This restriction will make...

  • Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c...

    Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c * * Purpose: implements a recursive function for determining *   if a string is a palindrome * * Authors: Steven R. Vegdahl, Tammy VanDeGrift, Martin Cenek * *****************************************************************/ #include #include #include /***************************************************************** * is_palindrome - determines whether a string of characters is a palindrome * * calling sequence: *    result = is_palindrome(str, first_index, last_index) * * parameters - *    str - the string to test *    first_index -...

  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • \\ this is the code i need help to get this part working the rest works...

    \\ this is the code i need help to get this part working the rest works but this and im not sure what is missing or how to make it work. this is what they asking for to do and there is two errors the ones shown in the pictures this is all the information I have from zybooks\\ Q3. (54 Points) Complete a public class to represent a Movie as described below. (a-e 4 pts each) (f-h 8 pts...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

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