fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Scanner;
  7. import java.util.Timer;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. Scanner abc = new Scanner(System.in);
  15. System.out.println(" Quiz Part 1 ");
  16. System.out.println("Rules:");
  17. System.out.println("1. Type in the correct answer for each question.");
  18. System.out.println("2. If anything else is inputed, it is wrong.");
  19. System.out.println("Type ok if you want to begin");
  20. String a = abc.nextLine();
  21. int total = 0;
  22.  
  23. if (a.equalsIgnoreCase("ok")) {
  24. System.out.println("Lets Start");
  25. } else {
  26. System.out.println("Thats not right,but lets start!");
  27.  
  28. }
  29.  
  30. int c = 0;
  31. Scanner scan = new Scanner(System.in);
  32. System.out.println("1. What's 2 + 2 ");
  33. System.out.println("4");
  34. System.out.println("2");
  35. System.out.println("1");
  36. System.out.println("3\n");
  37. String in;
  38. in = scan.nextLine();
  39.  
  40. if (in.equals("4")) {
  41. System.out.println("Correct\n");
  42. c++;
  43. } else {
  44. System.out.println("Wrong\n");
  45. }
  46. System.out.println("2. What Language Is This Coded IN\n");
  47.  
  48. System.out.println("C");
  49. System.out.println("C++");
  50. System.out.println("Java");
  51. System.out.println("PC");
  52. in = scan.nextLine();
  53. if (in.equalsIgnoreCase("Java")) {
  54. System.out.println("Correct");
  55. c++;
  56. } else {
  57. System.out.println("Wrong");
  58. }
  59. System.out.println("3. What, is the correct symbol for a remark?\n");
  60. System.out.println("//");
  61. System.out.println("^^");
  62. System.out.println("!!");
  63. System.out.println("**");
  64. System.out.println("");
  65. in = scan.nextLine();
  66. if (in.equalsIgnoreCase("")) {
  67. System.out.println("Correct");
  68. c++;
  69. } else {
  70. System.out.println("Wrong");
  71. }
  72. System.out.println("4. If you want to store a sentence in a variable, what type do you use?\n");
  73. System.out.println("Int");
  74. System.out.println("Double");
  75. System.out.println("Triple");
  76. System.out.println("string");
  77.  
  78. in = scan.nextLine();
  79. if (in.equalsIgnoreCase("String")) {
  80. System.out.println("Correct");
  81. c++;
  82. } else {
  83. System.out.println("Wrong");
  84. }
  85. System.out.println("5. Which one is illegal?\n");
  86. System.out.println(" String s=”I am”");
  87. System.out.println("Double a=45");
  88. System.out.println("Double d= 45.5");
  89. System.out.println(" Int=56.5");
  90.  
  91. in = scan.nextLine();
  92. if (in.equalsIgnoreCase(" Int=56.5")) {
  93. System.out.println("Correct");
  94. c++;
  95. } else {
  96. System.out.println("Wrong");
  97. }
  98. System.out.println("6. Which of the following can’t be assigned to Character data type?\n");
  99. System.out.println(" Letter");
  100. System.out.println("Digit");
  101. System.out.println("Special Character");
  102. System.out.println("String");
  103. System.out.println("");
  104. in = scan.nextLine();
  105. if (in.equalsIgnoreCase("String")) {
  106. System.out.println("Correct");
  107. c++;
  108. } else {
  109. System.out.println("Wrong");
  110. }
  111. System.out.println("7. What identifier sets a variable as true or false?\n");
  112. System.out.println("boolean");
  113. System.out.println("char");
  114. System.out.println("double");
  115. System.out.println("int");
  116. System.out.println("");
  117. in = scan.nextLine();
  118. if (in.equalsIgnoreCase("boolean")) {
  119. System.out.println("Correct");
  120. c++;
  121. } else {
  122. System.out.println("Wrong");
  123. }
  124. System.out.println("8. Which of the following is smallest integer data type?\n");
  125. System.out.println("");
  126. System.out.println(" byte");
  127. System.out.println("int");
  128. System.out.println("long");
  129. System.out.println("short");
  130. in = scan.nextLine();
  131. if (in.equalsIgnoreCase(" byte")) {
  132. System.out.println("Correct");
  133. c++;
  134. } else {
  135. System.out.println("Wrong");
  136. }
  137. System.out.println("9. How would you correctly display, “Hello, how are you?”?\n");
  138. System.out.println("System.out.println(Hello, how are you?);");
  139. System.out.println("out.print(Hello, how are you?);");
  140. System.out.println("System.out.println(\"Hello, how are you?\")");
  141. System.out.println(".print(Hello, how are you?);");
  142. System.out.println("");
  143. in = scan.nextLine();
  144. if (in.equalsIgnoreCase("System.out.println(\"Hello, how are you?\")")) {
  145. System.out.println("Correct");
  146. c++;
  147. } else {
  148. System.out.println("Wrong");
  149. }
  150. System.out.println("10. What class expose methods such as power to, Pi, square root, and cube root?\n");
  151. System.out.println(" int");
  152. System.out.println("String");
  153. System.out.println("class");
  154. System.out.println("Math");
  155. System.out.println("");
  156. in = scan.nextLine();
  157. if (in.equalsIgnoreCase("Math")) {
  158. System.out.println("Correct");
  159. c++;
  160. } else {
  161. System.out.println("Wrong");
  162. }
  163. System.out.println("11. Which package needs to be imported so that you can accept user input?\n");
  164. System.out.println("java.awt.event");
  165. System.out.println("java.io");
  166. System.out.println("java.util");
  167. System.out.println("java.awt");
  168. System.out.println("");
  169. in = scan.nextLine();
  170. if (in.equalsIgnoreCase("java.io")) {
  171. System.out.println("Correct");
  172. c++;
  173. } else {
  174. System.out.println("Wrong");
  175. }
  176. System.out.println("12. Which keyword would you use to break out of a loop?\n");
  177. System.out.println("while");
  178. System.out.println("continue");
  179. System.out.println("for");
  180. System.out.println("break");
  181. System.out.println("");
  182. in = scan.nextLine();
  183. if (in.equalsIgnoreCase("break")) {
  184. System.out.println("Correct");
  185. c++;
  186. } else {
  187. System.out.println("Wrong");
  188. }
  189. System.out.println("13. What is the name of the process by which two or more strings are joined together?\n");
  190. System.out.println("charAt");
  191. System.out.println(" Method");
  192. System.out.println("Concatenation");
  193. System.out.println("Association");
  194. System.out.println("");
  195. in = scan.nextLine();
  196. if (in.equalsIgnoreCase("Concatenation")) {
  197. System.out.println("Correct");
  198. c++;
  199. } else {
  200. System.out.println("Wrong");
  201. }
  202. System.out.println("14.Which of the following GUI components can be included in a Java frame?\n");
  203. System.out.println("button");
  204. System.out.println("border");
  205. System.out.println("textbox, label, button, images");
  206. System.out.println("label");
  207. System.out.println("");
  208. in = scan.nextLine();
  209. if (in.equalsIgnoreCase("textbox, label, button, images")) {
  210. System.out.println("Correct");
  211. c++;
  212. } else {
  213. System.out.println("Wrong");
  214. }
  215. System.out.println("15. Which loop type would you use to repeat a task a set number of times?\n");
  216. System.out.println("do-while");
  217. System.out.println(" switch");
  218. System.out.println("int");
  219. System.out.println("for");
  220. System.out.println("");
  221. in = scan.nextLine();
  222. if (in.equalsIgnoreCase("for")) {
  223. System.out.println("Correct");
  224. c++;
  225. } else {
  226. System.out.println("Wrong");
  227. }
  228. System.out.println("16. break statment is usedd to....\n");
  229. System.out.println("get out of method ");
  230. System.out.println("end a program");
  231. System.out.println("get out of a loop");
  232. System.out.println("get out of the system");
  233.  
  234. in = scan.nextLine();
  235. if (in.equalsIgnoreCase("get out of a loop")) {
  236. System.out.println("Correct");
  237. c++;
  238. } else {
  239. System.out.println("Wrong");
  240. }
  241. System.out.println("17. Which of the following is a legal name");
  242. System.out.println("goldNugget");
  243. System.out.println("slow.sally");
  244. System.out.println(" class");
  245. System.out.println("double");
  246.  
  247. in = scan.nextLine();
  248. if (in.equalsIgnoreCase("goldNugget")) {
  249. System.out.println("Correct");
  250. c++;
  251. } else {
  252. System.out.println("Wrong");
  253. }
  254. System.out.println(c + " Correct out of 17");
  255. System.out.println(100 * c / 17 + "%");
  256.  
  257. Scanner kbReader = new Scanner(System.in);
  258. System.out.println(" Quiz Part 2 ");
  259. System.out.println("Rules:");
  260. System.out.println("1. Write either true and false for each question.");
  261. System.out.println("2. If anything else is inputed, it is a zero.");
  262. System.out.println("Type ok if you want to begin");
  263. String b = kbReader.nextLine();
  264.  
  265. if (b.equalsIgnoreCase("ok")) {
  266. System.out.println("Lets Start Quiz part 1 ");
  267. } else {
  268. System.out.println("Thats not right,but lets start!");
  269. System.out.println("First Question!");
  270.  
  271. System.out.println("The name abc is a legal name for a variable.");
  272.  
  273. String i = kbReader.nextLine();
  274.  
  275. if (i.equalsIgnoreCase("true")) {
  276. System.out.println("Correct!");
  277. total++;
  278. } else if (i.equalsIgnoreCase("false")) {
  279. System.out.println("Wrong!");
  280. } else {
  281. System.out.println("Zero!(Read the Rules)");
  282. }
  283.  
  284. System.out.println("Second Question!");
  285. System.out.println("The variable int is used for any type of numbers.");
  286. String l = kbReader.nextLine();
  287. if (l.equalsIgnoreCase("false")) {
  288. System.out.println("Correct!");
  289. total++;
  290. } else if (l.equalsIgnoreCase("true")) {
  291. System.out.println("Wrong!");
  292. } else {
  293. System.out.println("Zero!(Read the Rules)");
  294. }
  295.  
  296. System.out.println("Third Question!");
  297. System.out.println("5 = p; is a legal way to assign a value to a variable.");
  298. String m = kbReader.nextLine();
  299. if (m.equalsIgnoreCase("false")) {
  300. System.out.println("Correct!");
  301. total++;
  302. } else if (m.equalsIgnoreCase("true")) {
  303. System.out.println("Wrong!");
  304. } else {
  305. System.out.println("Zero!(Read the Rules)");
  306. }
  307.  
  308. System.out.println("Fourth Question!");
  309. System.out.println("char is a indentifyer that sets a variable as true or false");
  310. String n = kbReader.nextLine();
  311. if (n.equalsIgnoreCase("false")) {
  312. System.out.println("Correct!");
  313. total++;
  314. } else if (n.equalsIgnoreCase("true")) {
  315. System.out.println("Wrong!");
  316. } else {
  317. System.out.println("Zero!(Read the Rules)");
  318. }
  319.  
  320. System.out.println("Fifth Question!");
  321. System.out.println("x--; means the same as x = x -1;");
  322. String o = kbReader.nextLine();
  323. if (o.equalsIgnoreCase("true")) {
  324. System.out.println("Correct!");
  325. total++;
  326. } else if (o.equalsIgnoreCase("false")) {
  327. System.out.println("Wrong!");
  328. } else {
  329. System.out.println("Zero!(Read the Rules)");
  330. }
  331.  
  332. System.out.println("Sixth Question!");
  333. System.out.println("Is the output true or false? System.out.println( (jj = = 40) && !false)");
  334. String p = kbReader.nextLine();
  335. if (p.equalsIgnoreCase("true")) {
  336. System.out.println("Correct!");
  337. total++;
  338. } else if (p.equalsIgnoreCase("false")) {
  339. System.out.println("Wrong!");
  340. } else {
  341. System.out.println("Zero!(Read the Rules)");
  342. }
  343.  
  344. System.out.println("Seventh Question!");
  345. System.out.println();
  346. System.out.println("The data type 'double' uses only single quotes. Ex. char ch = 'h';");
  347. String q = kbReader.nextLine();
  348. if (q.equalsIgnoreCase("false")) {
  349. System.out.println("Correct!");
  350. total++;
  351. } else if (q.equalsIgnoreCase("true")) {
  352. System.out.println("Wrong!");
  353. } else {
  354. System.out.println("Zero!(Read the Rules)");
  355. }
  356.  
  357. System.out.println("Eighth Question!");
  358. System.out.println("Is the output true or false? System.out.println(true && false);");
  359. String r = kbReader.nextLine();
  360. if (r.equalsIgnoreCase("false")) {
  361. System.out.println("Correct!");
  362. total++;
  363. } else if (r.equalsIgnoreCase("true")) {
  364. System.out.println("Wrong!");
  365. } else {
  366. System.out.println("Zero!(Read the Rules)");
  367. }
  368.  
  369. System.out.println("Ninth Question!");
  370. System.out.println("J = 69 is an example of an initializing expression");
  371. String t = kbReader.nextLine();
  372. if (t.equalsIgnoreCase("true")) {
  373. System.out.println("Correct!");
  374. total++;
  375. } else if (t.equalsIgnoreCase("false")) {
  376. System.out.println("Wrong!");
  377. } else {
  378. System.out.println("Zero!(Read the Rules)");
  379. }
  380.  
  381. System.out.println("Tenth Question!");
  382. System.out.println("There are only 10 digits in the decimal system.(0,1,2,3,4,5,6,7,8,9)");
  383. String u = kbReader.nextLine();
  384. if (u.equalsIgnoreCase("true")) {
  385. System.out.println("Correct!");
  386. total++;
  387. } else if (u.equalsIgnoreCase("false")) {
  388. System.out.println("Wrong!");
  389. } else {
  390. System.out.println("Zero!(Read the Rules)");
  391. }
  392.  
  393. System.out.println("Eleventh Question!");
  394. System.out.println("The Scanner class allows the user to input data from his or her keyboard?");
  395. String j = kbReader.nextLine();
  396. if (j.equalsIgnoreCase("true")) {
  397. System.out.println("Correct!");
  398. total++;
  399. } else if (u.equalsIgnoreCase("false")) {
  400. System.out.println("Wrong!");
  401. } else {
  402. System.out.println("Zero!(Read the Rules)");
  403. }
  404.  
  405. System.out.println(" Twelth Question!");
  406. System.out.println("There are 5 variables in java");
  407. String g1 = kbReader.nextLine();
  408. if (g1.equalsIgnoreCase("false")) {
  409. System.out.println("Correct!");
  410. total++;
  411. } else if (u.equalsIgnoreCase("true")) {
  412. System.out.println("Wrong!");
  413. } else {
  414. System.out.println("Zero!(Read the Rules)");
  415. }
  416. System.out.println(" Thirteeth Question!");
  417. System.out.println("The int identifier defines a 32-bit number without a decimal place?");
  418. String g2 = kbReader.nextLine();
  419. if (g2.equalsIgnoreCase("true")) {
  420. System.out.println("Correct!");
  421. total++;
  422. } else if (u.equalsIgnoreCase("false")) {
  423. System.out.println("Wrong!");
  424. } else {
  425. System.out.println("Zero!(Read the Rules)");
  426. }
  427. System.out.println(" Fourteeth Question!");
  428. System.out.println(".Comments should be included to explain the purpose of the program and explain processing steps");
  429. String g3 = kbReader.nextLine();
  430. if (g3.equalsIgnoreCase("true")) {
  431. System.out.println("Correct!");
  432. total++;
  433. } else if (u.equalsIgnoreCase("false")) {
  434. System.out.println("Wrong!");
  435. } else {
  436. System.out.println("Zero!(Read the Rules)");
  437. }
  438. System.out.println(" Fifteenth Question!");
  439. System.out.println("GUI stands for gimme Ur Internet");
  440. String g4 = kbReader.nextLine();
  441. if (g4.equalsIgnoreCase("false")) {
  442. System.out.println("Correct!");
  443. total++;
  444. } else if (u.equalsIgnoreCase("true")) {
  445. System.out.println("Wrong!");
  446. } else {
  447. System.out.println("Zero!(Read the Rules)");
  448. }
  449. System.out.println(total + " out of 15");
  450. System.out.println(total * 100 / 15 + ("%"));
  451. System.out.println("Total score");
  452. System.out.println(total + c + "out of 32");
  453. System.err.println(total + c * 100/ 30 + ("%"));
  454. System.out.println("Thank you for doing the quiz and hope you tried your best because your grade depends on it ");
  455. }
  456. }
  457.  
  458. }
  459. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:459: error: class, interface, or enum expected
}
^
1 error
stdout

Standard output is empty