Help Help help plzzzzzzz

hello i am new to java and i am trying to do the program will only calculate the costs of either a call to Germany or a call to India. The cost of a call to Germany is a $0.99 connection fee for any call, $1.00 for the first three minutes, and $0.25 for each additional minute over 3. The cost of a call to India is a $1.99 connection fee, $2.00 for the first three minutes, and $0.45 for each additional minute over 3. The program will ask the user to enter a character representing the country called and determine if the country entered is valid. If an invalid country is entered, the program will print a message to that effect but will not calculate the cost of the call. If the country entered by the user is valid, the program will prompt the user for the number of minutes the call lasted, calculate the cost of the call to that country, and display the cost.

import java.io.*;
import java.text.DecimalFormat;
public class PhoneCallBilling_Lab4
static BufferedReader keyboard = new
BufferedReader(new InputStreamReader(System.in));
//Named constants
static final double CONNECTION_FEE = 1.99;
static final double FIRST_THREE_MIN_FEE = 2.00;
static final double COST_OF_EACH_ADDITIONAL_MIN = 0.45;
public static void main(String[] args) throws IOException
//Variable declaration
int noOfMinCallLasted;
double amountDue;
DecimalFormat twoDigits =
new DecimalFormat("0.00");
System.out.println("This program computes an international phone call.");
System.out.print("Enter the number of minutes the call lasted: ");
noOfMinCallLasted =
Integer.parseInt(keyboard.readLine());
System.out.println();
if (noOfMinCallLasted<= 3)
amountDue = CONNECTION_FEE +
FIRST_THREE_MIN_FEE;
else
amountDue = CONNECTION_FEE +
FIRST_THREE_MIN_FEE +
(noOfMinCallLasted - 3) * COST_OF_EACH_ADDITIONAL_MIN;
System.out.println("The number of minutes the call lasted was "
+ noOfMinCallLasted);
System.out.println("Amount due = $"
+ twoDigits.format(amountDue));
}  

Similar Messages

  • URGENT HELP PLZZZZZZZ....

    HI EXPERTS,
    I HAVE 2 QUERIES TO ASK U..
    1).
    I AM ENHANCING AN INFOTYPE...
      I WANT THAT MY FIELD HAVE TO DISPLAY IN SOME SPECIFIC SUBTYPE ONLY..
    I NEVER IMPLEMENT WID SUBTYPE..
    SO ANYBODY PLZ HELP ME OR SEND ME THE CODE BY WHICH I CAN DO THIS...
    I WANT TO KNOW IMPLEMENATION WID SUBTYPE...
    SO GUIDE ME OR GIVE EXAMPLE FOR THIS..
    2).
    I HAVE IMPLEMENTED 0007 INFOTYPE WID MY ADDITIONAL FIELD..
    BUT I WANT THAT WHEN I SELECT MY DATA IN ADDITIONAL FIELD THAN IT AFFECTS ON STANDARD TABLE ALSO..
    I MEAN 2 SAY HOW CAN I DO THIS WHERE MY SELECTION AFFECTS ON OTHER FIELD AND I CAN SAVE IT IN TABLE..
    HELP ME ASAP...
    THANKS IN ADVANCE..
    POINTS WILL BE REWARDED...
    REGARDS,
    Bhumit Mehta

    ITs very difficult to find whats ur previous post..and when it is done..if u need some help send a mail across to [email protected] with detailed description

  • 6680 keypad lights,help plzzzzzzz

    i just bought a new nokia 6680 and with every other phone i've had when you press the buttons the keypad lights up????!but the keys on my nokia 6680 sometimes light up when i press a button and sometimes dont???????? is this normal

    In the upper left corner in the front of the phone there's an ambient light sensor that has an impact on the keypad lights and display brightness.
    When the phone is in a bright environment according to the sensor, the keypad doesn't light up unnecessarily.
    When it is dark[er], the keypad lights turn on.
    Helps conserve battery power.

  • Hp dv 7 urgent plzzzzzzz help

    Hi guys , i wish that al of you are in good health , OK let's move to my problem and plz I Need serious help , I have a hp dv7 1240 ek a very beautiful laptop and i love it but week ago its fan stopped working suddenly without any reason !!  so i decided to dissemble it and try to plug the fan again and see what is going to happen again i have faced a problem the screws are stripped and in bad state i think hp is responsible for this . so what do you think should I try and continue my plan or carry it to my seller  ' i do not appreciate this idea

    The heatsink screws are spring loaded and they might seem stripped but there is a technique to get them out of there. I have never seen an HP laptop or any other come from the factory with stripped heatsink screws. I have, however, seen a few with stripped heatsink screws where customers come in and ask me to just look at a system they already started working on but are stuck. I am not saying that is what you did, because I have not seen your laptop; I am just saying.

  • Cant login my macbook pro....PLZZZZZZZ HELP

    hey...
    this morning i switched on my mac and on the login screen i entered my password, but i didnt work. M pretty much sure that the password is correct plz help me out. My mac book's version is 10.6.4
    plz plz plzzzz help me out
    thanks

    Boot from your OS X installation or "system install" disc by holding down the "C" key while rebooting with that disc in the optical drive.  Early in the installation process you should see a "Utilities" menu.  In that should be an option to reset your password.

  • Question on JFrame, help me plzzzzzzz!!!

    Hi my friend:
    I need your help on JFrame urgently. As we know, we close a JFrame by clicking the close button on the window title pane. Now I want to change this default for my JFrame. So that when someone click the close button, an Joptionpane is pop out to confirm the closing action. The JFrame will only be closed by clicking the "OK" button on the Joptionpane. If click cancel, optionpane disappear. How to do this? Pls guide me.

    close a JFrame by clicking the close button on the
    window title pane. Now I want to change this default
    for my JFrame. 1) http://java.sun.com/j2se/1.3/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation(int)
    So that when someone click the close
    button, an Joptionpane is pop out to confirm the
    closing action. The JFrame will only be closed by
    clicking the "OK" button on the Joptionpane. If click
    cancel, optionpane disappear.2)
    if(JOptionPane.showConfirmDialog(JFrame.this,"Really close?","Confirm Window Closing", JOptionPane.YES_NO_CANCEL_OPTION)==?){
    //do something...
    }the ? means you can figure it out yourself with the documentation...
    http://java.sun.com/j2se/1.3/docs/api/javax/swing/JOptionPane.html

  • Illegal state exception in filters can any help me plzzzzzzz

    i want to check the clients status i mean whether the request is coming from new client or already using client , if clients request is new one then the filter has to redirect to some other login page and also if the request is asked to access the authenticated resource then also he want to force to redirect to login page.If the user is logged in and his session is not expired and if session is valid then he can access the requested url as per his role....can any one suggest the code plzzzzzzzzz
    here is my code but iam getting the illegal state exception as shown below...
    package uk.co.lex.interactive.authentication.action;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class AuthenticationFilter implements Filter {
    private FilterConfig filterConfig=null;
    HttpSession session=null;
         public void init(FilterConfig filterConfig) throws ServletException {
              //TODO Auto-generated method stub
              this.filterConfig=filterConfig;
              System.out.println("---Authentication filter initialized---");
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              // TODO Auto-generated method stub
              HttpServletRequest req=(HttpServletRequest)request;
              HttpServletResponse res=(HttpServletResponse)response;
                   String reqSessId=req.getRequestedSessionId();
              if(reqSessId!=null)
                   {System.out.println("-------session is valid and the same client is using the resource111---");
                         if(req.isRequestedSessionIdValid())
                            System.out.println("-------session is valid and the same client is using the resource222---");
                            System.out.println("---requested sessid"+reqSessId);
                           if(req.isRequestedSessionIdFromCookie()||req.isRequestedSessionIdFromURL())
                                System.out.println("-------session is valid and the same client is using the resource333---");
              }else
              res.sendRedirect(req.getContextPath()+"/"+"checkUser.do");
                        System.out.println("------it is new session so it redirected to loginpage from authentication filter-------");
              else
                   res.sendRedirect(req.getContextPath()+"/"+"checkUser.do");
                   System.out.println("------it is new session so it redirected to loginpage from authentication filter-------");
              chain.doFilter(request,response);
         public void destroy() {
              // TODO Auto-generated method stub
              this.filterConfig=null;
              System.out.println("-----authentication filter destroyed---");
    11:03:18,693 ERROR [[action]] Servlet.service() for servlet action threw exception
    java.lang.IllegalStateException: Cannot create a session after the response has been committed
         at org.apache.catalina.connector.Request.doGetSession(Request.java:2195)
         at org.apache.catalina.connector.Request.getSession(Request.java:2017)
         at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:822)
         at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
         at org.apache.struts.action.RequestProcessor.processLocale(RequestProcessor.java:621)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:177)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at uk.co.lex.interactive.authentication.action.AuthenticationFilter.doFilter(AuthenticationFilter.java:63)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:595)

    I don't know that this is the root cause of your problem, but it certainly could be. When comparing two strings, you need to use the .equals() method, not ==.
    (except in the null case, where checking for null with == is perfectly okay).
    if (ViewProtectedPage.getValue("trycount").equals("1")
    ..etc
    Some other notes... use if/else if/else rather than a whole bunch of ifs, since all your statements are mutually exclusive. Maybe even put those lower ifs inside your outer "else" since you're obviously not going to reach them after a sendRedirect(). On that same note, place a return; after the sendRedirect() to state that the rest of the page need not be loaded/executed.

  • ODI error with OBI APPs7.9.5.2 help me plzzzzzzz

    Dear All,
    I installed the OBI Apps7.9.5.2 and when I installed The ODI and when I want to execute this commands
    agentservice –i –s WORKFLOW 20910
    agentservice –i –a INTERFACE 20911
    it says that JDK must be required instead of jre .
    How I can solve this issue PLzzzzzzzzzzzzzzz,
    Thanks in Advance ,
    Zaki

    hi Zaki,
    Can you please post the ODI related stuff at ODI forum or search the error message in the odi forum
    Data Integrator
    Thanks,
    Saichand Varanasi

  • Interface problem!! PLZZZZ help!

    Hi,
    dis problem is probably gna make me look really stupid but i jus cnt seem to work it out. Basically, im tryin to implement my system to use rmi. I wrote my rmi interface class, and compiled it. No problem. Then i wrote my rmi server class which implements the interface. But when i try to compile the server, i get an error sayin "cannot resolve symbol" which is refering to my interface. Im totally clueless as to why this is happening. PLZZZZZZZ could some1 gimme some input.
    The interface is called GamesDB.java. The server class is GamesDBImpl.java. The error occurs on this line in my server class:
    public class GamesDBImpl extends UnicastRemoteObject implements GamesDB
    sayin that it cannot resolve the symbol GamesDB. Please help!! Thanks in advance!!

    Isn't there an issue (or more correctly something
    fixed) in the new 1.4 that means classes in the same
    package are no longer found without explicitly
    importing them?
    Barring that, is the interface in another package, in
    which case it definitely needs to be imported?
    Does your interface extend Remote?
    Is your classpath set up correctly?
    Just some quick thoughts.Have never used 1.4 yet but if apparently that seems to be the only problem. Try using import statement.

  • Problem with threads and simulation: please help

    please help me figure this out..
    i have something like this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DrawShapes extends JApplet{
         private JButton choices[];
         private String names[]={"line", "square", "oval"};
         private JPanel buttonPanel;
         private DrawPanel drawingArea;
         private int width=300, height=200;
         public void init(){
              drawingArea=new DrawPanel(width, height);
              choices=new JButton[names.length];
              buttonPanel=new JPanel();
              buttonPanel.setLayout(new GridLayout(1, choices.length));
              ButtonHandler handler=new ButtonHandler();
              for(int i=0; i<choices.length; i++){
                   choices=new JButton(names[i]);
                   buttonPanel.add(choices[i]);
                   choices[i].addActionListener(handler);
              Container c=getContentPane();
              c.add(buttonPanel, BorderLayout.NORTH);
              c.add(drawingArea, BorderLayout.CENTER);
         }//end init
         public void setWidth(int w){
              width=(w>=0 ? w : 300);
         public void setHeight(int h){
              height=(h>=0 ? h : 200);
         /*public static void main(String args[]){
              int width, height;
              if(args.length!=2){
                   height=200; width=300;
              else{
                        width=Integer.parseInt(args[0]);
                        height=Integer.parseInt(args[1]);
              JFrame appWindow=new JFrame("An applet running as an application");
              appWindow.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              DrawShapes appObj=new DrawShapes();
              appObj.setWidth(width);
              appObj.setHeight(height);
              appObj.init();          
              appObj.start();
              appWindow.getContentPane().add(appObj);
              appWindow.setSize(width, height);
              appWindow.show();
         }//end main*/
         private class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   for(int i=0; i<choices.length; i++){
                        if(e.getSource()==choices[i]){
                             drawingArea.setCurrentChoice(i);
                             break;
    }//end class DrawShapes
    class DrawPanel extends JPanel{
         private int currentChoice=-1;
         private int width=100, height=100;
         public DrawPanel(int w, int h){
              width=(w>=0 ? w : 100);
              height=(h>=0 ? h : 100);
         public void paintComponent(Graphics g){
              super.paintComponent(g);
              switch(currentChoice){
                   case 0:     g.drawLine(randomX(), randomY(), randomX(), randomY());
                             break;
                   case 1: g.drawRect(randomX(), randomY(), randomX(), randomY());
                             break;
                   case 2: g.drawOval(randomX(), randomY(), randomX(), randomY());
                             break;
         public void setCurrentChoice(int c){
              currentChoice=c;
              repaint();          
         private int randomX(){
              return (int) (Math.random()*width);
         private int randomY(){
              return (int) (Math.random()*height);
    }//end class drawPanel
    That one's from a book. I used that code to start with my applet. Mine calls different merthod from the switch cases. Say I have:
    case 0: drawStart(g); break;
    public void drawStart(Graphics g){
      /* something here */
    drawMain(g);
    public void drawMain(graphics g){
    g.drawString("test", x, y);
    //here's where i'm trying to pause
    //i've tried placing Thread.sleep between these lines
    g.drawLine(x, y, a, b);
    //Thread.sleep here
    g.drawRect(x, y, 50, 70);
    }I also need to put delays between method calls but I need to synchronize them. Am I doing it all wrong? The application pauses or sleeps but afterwards, it still drew everything all at once. Thanks a lot!

    It is. Sorry about that. Just answer any if you want to. I'd appreciate your help. Sorry again if it caused you anything or whatever. .n_n.

  • Query Help

    Table1:
    ou store point
    LS LIB1 50
    LS LIB1 200
    LS LIB1 100
    LS LIB1 79
    I have to insert table1 to table2 by splitting into every 143point and assing serial number for every 143 from parameter.
    in aboce example we can split 3 time 143 like below table2 sample.
    Table2
    ou store point serial_number
    LS LIB1 50 101
    LS LIB1 93 101
    LS LIB1 107 102
    LS LIB1 36 102
    LS LIB1 64 103
    LS LIB1 79 103
    i tried below procedure its not working.
    table may have any order like below.
    Table1:
    ou store point
    LS LIB1 200
    LS LIB1 50
    LS LIB1 100
    LS LIB1 79
    then table2
    ou store point serial_number
    LS LIB1 143 101
    LS LIB1 57 102
    LS LIB1 50 102
    LS LIB1 36 102
    LS LIB1 64 103
    LS LIB1 79 103
    create or replace procedure assign_serial(from_num number,to_num number) is
    bal number(10);
    begin
    bal := 0;
    for c1 in(select * from table1)
    loop
    if c1.point <=143 then
    if bal=0 then
    bal=143-used;
    insert int0 table2 values(c1.ou,c1.store,used);
    elsif used > 0 then
    used=used-bal;
    insert int0 table2 values(c1.ou,c1.store,bal);
    bal=0;
    if used > 0 then
    insert int0 table2 values(c1.ou,c1.store,used);
    end if;
    bal:=143-used;
    end if;
    end loop;
    end;
    How to split and assign serial number,please hELP.

    .after giving serial num i have to change points in table1 to 0.The problem for SUm and split for every 143 is ,different OU and store is there.we have to know for which store points we earned serial number.
    i hope this below logic little satisfy except assign cardnum,please........ check and currect the logic
    LS LIB1 50
    LS LIB1 200
    LS LIB1 100
    LS LIB1 79
    --variable used and bal
    for c1 in(select * from table1)
    loop
    used := c1.points;
    if c1.point <=143 then
    if bal=0 then
    bal=143-used;
    insert int0 table2 values(c1.ou,c1.store,used);
    elsif used > 0 then
    used=used-bal;
    insert int0 table2 values(c1.ou,c1.store,bal);
    bal=0;
    if used > 0 then
    insert int0 table2 values(c1.ou,c1.store,used);
    end if;
    bal:=143-used;
    end if;
    end loop;

  • Help my safari doesnt open and gives me a crash report

    help my safari doesn't open and gives me a crash report ever since i downloaded a file from the internet. I have a macbook air (early 2014) with running os x yosemite version 10.10.1

    There is no need to download anything to solve this problem.
    You may have installed the "Genieo" or "InstallMac" ad-injection malware. Follow the instructions on this Apple Support page to remove it.
    Back up all data before making any changes.
    Besides the files listed in the linked support article, you may also need to remove this file in the same way:
    ~/Library/LaunchAgents/com.genieo.completer.ltvbit.plist
    If there are other items with a name that includes "Genieo" or "genieo" alongside any of those you find, remove them as well.
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those. If Safari crashes on launch, skip that step and come back to it after you've done everything else.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, then you may have one of the other kinds of adware covered by the support article. Follow the rest of the instructions in the article.
    Make sure you don't repeat the mistake that led you to install the malware. Chances are you got it from an Internet cesspit such as "Softonic" or "CNET Download." Never visit either of those sites again. You might also have downloaded it from an ad in a page on some other site. The ad would probably have included a large green button labeled "Download" or "Download Now" in white letters. The button is designed to confuse people who intend to download something else on the same page. If you ever download a file that isn't obviously what you expected, delete it immediately.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates
    if it's not already checked.

  • Apple Mini DVI to Video Adapter is not working. Please Help...

    I bought an Apple Mini DVI to Video Adapter to connect my Macbook to a TV using normal video cable. When I connect the cable, my Laptop DIsplay gives a flickr once and then it shows nothing. I checked Display in the system preference where I don't get a secondary monitor option. My TV is panasonic and it's an old one. I work on Final Cut Pro and it's very very important to see my videos on a TV. What am I doing wrong with the connection? Anyone Please Please help...

    Your probably not doing anything wrong. There are thousands of users with Similar issues and it seems to be with many different adapters.
    We have Mini DP to VGA (3 different brands) and they all fail most of the time. This seems more prevalent with LCD Projectors. I've tested some (50+) with VGA Monitor (HP) and they all worked, LCD Projector (Epson, Hitachi, and Sanyo) and they all fail, DLP Projector (Sanyo) and one worked.
    My Apple Mini DP to DVi works most of the time. My Mini DP to HDMI (Generic non Apple) works every time.
    The general consensus is that Apple broke something in the OS around 10.6.4 or 10.6.5 and its not yet fixed. As we are a school we have logged a case with the EDU Support group so will see what happens.
    Dicko

  • Mini dvi to video adapter help pleaseeeeeeeeeeeeeeeeeeeeeeeeee

    right,
    ive got a 20" intel imac. i bought a mini dvi to video adapter.it said it works with the intel macs.
    i maybe being a bit thick here but the end of the dvi seems to be a different size to the port on the mac.
    please help....................

    You might find relief in the iMac Forum. Perhaps they will appreciate your distinctive thread header style more fully.
    good luck.
    x

  • PSE icons instead of the photo. I need to view photos at a glance. Please help me????

    Please help, this is driving me crazy.  I have downloaded my free PSE #9, it came with my Leica Camera.  I cannot view at a glance any of my photos.  There is only an icon that reads, PSE.  To view any of my photos, I must click select and then preview.  This gets old, and I am doing 4 times the work. I am having to use the dates to guess where my photos might be.  I hate this!  My old Photo Shop #5 didn't do this.  When you went to my pictures, you could see every photo.
    I have tried the right click and open as any program.  What ever program I choose, that is the icon that appears.  No photo. Still no good.
    Please help.
    Thanking anyone in advance,
    Leica

    Hi,
    Are you using Windows Explorer to view the files?
    If so, load Explorer, go to the Tools menu and select Folder Options.
    Click on the View tab and make sure the first option (Always show icons, never thumbnails) is not checked.
    Click on OK and see if that is any better.
    Brian

Maybe you are looking for