d. fullName="Harris, Ray"
Explanation:
// here we define two variables firstName="Ray" and lastName= "Harris"
var firstName = "Ray", lastName = "Harris";
// then we create another variable fullName and assign it the value stored in variabl lastName that is "Harris"
var fullName = lastName;
// then we added a coma and space. At this point fullName= Harris,
fullName += ", ";
// then we added firstName to the variable fullName. At this point fullName=Harris, Roy
fullName += firstName;
Note: the += operator means that add the variable on the left by an amount on the right
a+= b; or a = a + b; both mean same
d. fullName="Harris, Ray"
Explanation:
// here we define two variables firstName="Ray" and lastName= "Harris"
var firstName = "Ray", lastName = "Harris";
// then we create another variable fullName and assign it the value stored in variabl lastName that is "Harris"
var fullName = lastName;
// then we added a coma and space. At this point fullName= Harris,
fullName += ", ";
// then we added firstName to the variable fullName. At this point fullName=Harris, Roy
fullName += firstName;
Note: the += operator means that add the variable on the left by an amount on the right
a+= b; or a = a + b; both mean same
Name an event that is impossible: Drawing the name "John" out of the bag
Name and event that is certain: Drawing a name that starts with the letter "J"
Name an event that is as likely as not: Drawing a girl's name or a boy's name
Name an event that is more likely than not: Drawing a name that is longer than 4 letters.
Step-by-step explanation:
Name an event that is impossible: Drawing the name "John" out of the bag
Name and event that is certain: Drawing a name that starts with the letter "J"
Name an event that is as likely as not: Drawing a girl's name or a boy's name
Name an event that is more likely than not: Drawing a name that is longer than 4 letters.
Step-by-step explanation:
1. C
2. E
3. A
4. Ab
5. Db
6. C#
7. C
8. D#
9. A
10. C#
11. E
12. G#
Explanation: Sorry I took awhile I went AFK for a moment
1. C
2. E
3. A
4. Ab
5. Db
6. C#
7. C
8. D#
9. A
10. C#
11. E
12. G#
Explanation: Sorry I took awhile I went AFK for a moment
Explanation:
The following is written in Python. It creates the dictionary as requested and prints it out to the output file as requested using the correct format for various shows with the same number of seasons.The output can be seen in the attached picture below.
mydict = {}
with open("file1.txt", "r") as showFile:
for line in showFile:
cleanString = line.strip()
seasons = 0
try:
seasons = int(cleanString)
print(type(seasons))
except:
pass
if seasons != 0:
showName = showFile.readline()
if seasons in mydict:
mydict[seasons].append(showName.strip())
else:
mydict[seasons] = [showName.strip()]
f = open("output.txt", "a")
finalString = ''
for seasons in mydict:
finalString += str(seasons) + ": "
for show in mydict[seasons]:
finalString += show + '; '
f.write(finalString[:-2] + '\n')
finalString = ''
f.close()
Couplet.java
public class Couplet extends Poem
{
private final static int LINES = 2;
public Couplet(String poemName)
{
super(poemName, LINES);
}
}
Haiku.java
public class Haiku extends Poem
{
private static int LINES = 3;
public Haiku(String poemName)
{
super(poemName, LINES);
}
}
Limerick.java
public class Limerick extends Poem
{
private static int LINES = 5;
public Limerick(String poemName)
{
super(poemName, LINES);
}
}
Poem.java
public class Poem
{
private String poemName;
private int lines;
public Poem(String poemName, int lines)
{
this.poemName = poemName;
this.lines = lines;
}
public String getPoemName()
{
return poemName;
}
public int getLines()
{
return lines;
}
}
DemoPoem.java
import java.util.*;
public class DemoPoems
{
public static void main(String[] args)
{
Poem poem1 = new Poem("The Raven", 84);
Couplet poem2 = new Couplet("True Wit");
Limerick poem3 = new Limerick("There was an Old Man with a Beard");
Haiku poem4 = new Haiku("The Wren");
display(poem1);
display(poem2);
display(poem3);
display(poem4);
}
public static void display(Poem p)
{
System.out.println("Poem: " + p.getPoemName() +
" Lines: " + p.getLines());
}
}
Explanation:
The Couplet and Limerick classes should also be extended from Poem class. Also, in display method, you call getTitle(), however, it's written as getPoemName() in the Poem class. You need to change the name.
It will provide an instant answer!