Roman Invasion (While)

Map of Britain

Britain was a wealth country and began trading with the Roman Empire. Julius Caesar realized the value that Britain would bring to the Empire and undertook the first invasion. Here is a timeline of the Roman occupation of Britain.

  1. In 55 BCE Caesar invades but is driven off by Britons.
  2. In 56 BCE Caesar invades and is successful but the Romans withdraw.
  3. In 43 CE the Romans invade and begin the occupation of Southeast Britain.
  4. In 60 CE Boudicca leads a revolt against the Romans but is defeated.
  5. By 75 CE the Romans conquer Britain up to what is now Scotland.
  6. In 122 CE Hadrian's wall is begun to defend Britain from the Picts, and Scotts.

Notice the use of the import statement at the top of the code. This statement brings in the System.out method from the Java API so that you no longer need to type "System" when you wish to print.

This code illustrates the use of a Switch statement.

  1. //imports the System.out method from the Java API (application programming interfaces)
  2. import static java.lang.System.out;
  3. public class DemoSwitch {
  4. public static void main(String[] args) {
  5. String firstinv = "The first invaders were the Romans.";
  6. String secondinv = "The second invaders were the Anglo-Saxons.";
  7. String thirdinv = "The third invaders were the Jutes.";
  8. String fourthinv = "The fourth invaders were the Vikings.";
  9. String fifthinv = "The fifth invaders were the Normans.";
  10. int invnumber = 3;
  11. String invader;
  12. switch (invnumber) {
  13. case 1: invader = firstinv;
  14. break;
  15. case 2: invader = secondinv;
  16. break;
  17. case 3: invader = thirdinv;
  18. break;
  19. case 4: invader = fourthinv;
  20. break;
  21. case 5: invader = fifthinv;
  22. break;
  23. default: invader = "Invalid Month";
  24. Java code}
  25. out.println();
  26. out.println(invader);
  27. }

 

Use Save As to save the code to your folder as: DemoSwitch.java. Then compile the code in the Command prompt window. Use javac DemoSwitch.java to create the .class file. Execute the program. Use java DemoSwitch to run the program.

Your output should look like this:

c:\javamike>java DemoSwich

The third invaders were the Jutes.

< If Else Romans (While) >